KusStar / vite-plugin-glslify

A plugin for Vite to compile glslify shader code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

automatically add `rollup-plugin-glslify` for lib builds

micahscopes opened this issue · comments

commented

I'm using vite build to bundle a library and had to add both this plugin and rollup-plugin-glslify to avoid confusing rollup. Specifically, I was getting this error.

My plugins look like this:

import { glslify } from "vite-plugin-glslify";
import glslifyRollup from "rollup-plugin-glslify";
...
export default defineConfig({
  ...
  plugins: [glslify(), glslifyRollup()],
  ...
})

The full working vite.config.js:

import { defineConfig } from "vite";
import path, { dirname } from "path";
import { glslify } from "vite-plugin-glslify";
import glslifyRollup from "rollup-plugin-glslify";

const glslifyOptions = {
  extensions: ["vs", "fs", ".glsl", ".frag.shader"],
  compress: true,
  transform: ["glslify-import"],
};

export default defineConfig({
  plugins: [glslify(glslifyOptions), glslifyRollup(glslifyOptions)],

  build: {
    lib: {
      entry: path.resolve(dirname("src/index.js")),
      name: "my library",
      fileName: (format) => `my-library.${format}.js`,
    },
  },
});