When working with CSS modules in Sass files and including multi-line comments inside of a :global declaration, the production build shows a warning.
vite v2.9.9 building for production...
✓ 31 modules transformed.
warnings when minifying css:
▲ [WARNING] Unexpected "{"
<stdin>:1:1:
1 │ {
╵ ^
Removing the multi-line comment results in a proper build output with no warnings.
> vite build --debug
vite:config bundled config file loaded in 99.63ms +0ms
vite:config using resolved config: {
vite:config plugins: [
vite:config 'vite:build-metadata',
vite:config 'alias',
vite:config 'vite:react-babel',
vite:config 'vite:react-refresh',
vite:config 'vite:react-jsx',
vite:config 'vite:modulepreload-polyfill',
vite:config 'vite:resolve',
vite:config 'vite:html-inline-proxy',
vite:config 'vite:css',
vite:config 'vite:esbuild',
vite:config 'vite:json',
vite:config 'vite:wasm',
vite:config 'vite:worker',
vite:config 'vite:asset',
vite:config 'vite:define',
vite:config 'vite:css-post',
vite:config 'vite:build-html',
vite:config 'vite:worker-import-meta-url',
vite:config 'vite:watch-package-data',
vite:config 'commonjs',
vite:config 'vite:data-uri',
vite:config 'rollup-plugin-dynamic-import-variables',
vite:config 'vite:asset-import-meta-url',
vite:config 'vite:build-import-analysis',
vite:config 'vite:esbuild-transpile',
vite:config 'vite:terser',
vite:config 'vite:reporter',
vite:config 'vite:load-fallback'
vite:config ],
vite:config build: {
vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config polyfillModulePreload: true,
vite:config outDir: 'dist',
vite:config assetsDir: 'assets',
vite:config assetsInlineLimit: 4096,
vite:config cssCodeSplit: true,
vite:config cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config sourcemap: false,
vite:config rollupOptions: {},
vite:config minify: 'esbuild',
vite:config terserOptions: {},
vite:config write: true,
vite:config emptyOutDir: null,
vite:config manifest: false,
vite:config lib: false,
vite:config ssr: false,
vite:config ssrManifest: false,
vite:config reportCompressedSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null,
vite:config commonjsOptions: { include: [Array], extensions: [Array] },
vite:config dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
vite:config },
vite:config resolve: { dedupe: [ 'react', 'react-dom' ], alias: [ [Object], [Object] ] },
vite:config optimizeDeps: {
vite:config include: [ 'react/jsx-dev-runtime' ],
vite:config esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
vite:config },
vite:config configFile: '/Users/mprzybylski/Desktop/vite-css-module-comment-bug/vite.config.js',
vite:config configFileDependencies: [
vite:config '/Users/mprzybylski/Desktop/vite-css-module-comment-bug/vite.config.js'
vite:config ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config build: {}
vite:config },
vite:config root: '/Users/mprzybylski/Desktop/vite-css-module-comment-bug',
vite:config base: '/',
vite:config publicDir: '/Users/mprzybylski/Desktop/vite-css-module-comment-bug/public',
vite:config cacheDir: '/Users/mprzybylski/Desktop/vite-css-module-comment-bug/node_modules/.vite',
vite:config command: 'build',
vite:config mode: 'production',
vite:config isWorker: false,
vite:config isProduction: true,
vite:config server: {
vite:config preTransformRequests: true,
vite:config fs: { strict: true, allow: [Array], deny: [Array] }
vite:config },
vite:config preview: {
vite:config port: undefined,
vite:config strictPort: undefined,
vite:config host: undefined,
vite:config https: undefined,
vite:config open: undefined,
vite:config proxy: undefined,
vite:config cors: undefined,
vite:config headers: undefined
vite:config },
vite:config env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen],
vite:config hasErrorLogged: [Function: hasErrorLogged]
vite:config },
vite:config packageCache: Map(0) { set: [Function (anonymous)] },
vite:config createResolver: [Function: createResolver],
vite:config worker: {
vite:config format: 'iife',
vite:config plugins: [
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object], [Object], [Object],
vite:config [Object]
vite:config ],
vite:config rollupOptions: {}
vite:config }
vite:config } +3ms
vite v2.9.9 building for production...
✓ 31 modules transformed.
warnings when minifying css:
▲ [WARNING] Unexpected "{"
<stdin>:1:1:
1 │ {
╵ ^
dist/index.html 0.44 KiB
dist/assets/index.fe5fb74e.css 0.31 KiB / gzip: 0.24 KiB
dist/assets/index.26a25dd7.js 139.63 KiB / gzip: 44.76 KiB
Describe the bug
When working with CSS modules in Sass files and including multi-line comments inside of a
:globaldeclaration, the production build shows a warning.Given the following code:
:global { /* * Add the correct display in all browsers. */ summary { display: list-item; } }When running
npm run buildit outputs the following CSS:{}summary{display:list-item}This shows the following warning during the build:
Removing the multi-line comment results in a proper build output with no warnings.
Reproduction
https://github.com/reintroducing/vite-css-module-comment-bug
System Info
System: OS: macOS 12.3.1 CPU: (10) arm64 Apple M1 Pro Memory: 82.06 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm Browsers: Chrome: 102.0.5005.61 Firefox: 97.0.1 Safari: 15.4 npmPackages: @vitejs/plugin-react: ^1.3.0 => 1.3.2 vite: ^2.9.9 => 2.9.9Used Package Manager
npm
Logs
Validations