Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vite-plugin-pwa fails when vite-plugin-glsl is also used #804

Closed
eugene-khyst opened this issue Dec 8, 2024 · 1 comment
Closed

vite-plugin-pwa fails when vite-plugin-glsl is also used #804

eugene-khyst opened this issue Dec 8, 2024 · 1 comment

Comments

@eugene-khyst
Copy link

eugene-khyst commented Dec 8, 2024

vite-plugin-pwa build fails when GLSL (*.glsl) files are processed with vite-plugin-glsl.

It looks like vite-plugin-pwa tries to treat *.glsl files as JS and fails.

But I can't find a way to instruct vite-plugin-pwa to ignore *.glsl files. There is no exclude or ignore configuration properties.

import react from '@vitejs/plugin-react';
import {defineConfig} from 'vite';
import glsl from 'vite-plugin-glsl';
import {VitePWA} from 'vite-plugin-pwa';

export default defineConfig({
  plugins: [
    glsl({
      compress: true,
    }),
    react(),
    VitePWA({
      strategies: 'injectManifest',
      srcDir: 'src',
      filename: 'service-worker.ts',
      manifest: false,
      injectRegister: false,
    }),
  ],

  worker: {
    plugins: () => [
      glsl({
        compress: true,
      }),
    ],
  },
});
x Build failed in 1.66s
error during build:
src/services/image/filter/glsl/color-correction.glsl (1:9): Expected ';', '}' or <eof> (Note that you need plugins to import files that are not JavaScript)
file: /home/evgeniy/projects/artistassistapp/src/services/image/filter/glsl/color-correction.glsl:1:9

1: #version 300 es
            ^
2: 
3: precision mediump float;

    at getRollupError (file:///home/evgeniy/projects/artistassistapp/node_modules/rollup/dist/es/shared/parseAst.js:395:41)
    at ParseError.initialise (file:///home/evgeniy/projects/artistassistapp/node_modules/rollup/dist/es/shared/node-entry.js:13252:28)
    at convertNode (file:///home/evgeniy/projects/artistassistapp/node_modules/rollup/dist/es/shared/node-entry.js:14963:10)
    at convertProgram (file:///home/evgeniy/projects/artistassistapp/node_modules/rollup/dist/es/shared/node-entry.js:14206:12)
    at Module.setSource (file:///home/evgeniy/projects/artistassistapp/node_modules/rollup/dist/es/shared/node-entry.js:15949:24)
    at async ModuleLoader.addModuleSource (file:///home/evgeniy/projects/artistassistapp/node_modules/rollup/dist/es/shared/node-entry.js:19827:13)
@eugene-khyst
Copy link
Author

It turned out that I need to add glsl plugin to injectManifest.buildPlugins.vite:

VitePWA({
  // ...
  injectManifest: {
    buildPlugins: {
      vite: [
        glsl({
          compress: true,
        }),
      ],
    },
  },
}),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant