vite: build includes @charset problem.

i have same problem.

image

css: { preprocessorOptions: { css: { charset: false } } } don’t working

_Originally posted by @mesutgok in https://github.com/vitejs/vite/issues/5655#issuecomment-979144222_

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 20 (5 by maintainers)

Most upvoted comments

Same issue and I ended up adding the following in vite.config.js:

  css: {
    postcss: {
      plugins: [
          {
            postcssPlugin: 'internal:charset-removal',
            AtRule: {
              charset: (atRule) => {
                if (atRule.name === 'charset') {
                  atRule.remove();
                }
              }
            }
          }
      ],
    },
}
css: {
    preprocessorOptions: {
      scss: {
        charset: false
      },
      less: {
        charset: false,
      },
    },
    charset: false,
    postcss: {
      plugins: [{
        postcssPlugin: 'internal:charset-removal',
        AtRule: {
          charset: (atRule) => {
            if (atRule.name === 'charset') {
              atRule.remove();
            }
          }
        }
      }],
    },
  }

It works for me!

FYI as per https://github.com/evanw/esbuild/issues/1862 upgrading to esbuild 0.14.6 fixed this for me (charset removal config no longer required)

Same issue and I ended up adding the following in vite.config.js:

  css: {
    postcss: {
      plugins: [
          {
            postcssPlugin: 'internal:charset-removal',
            AtRule: {
              charset: (atRule) => {
                if (atRule.name === 'charset') {
                  atRule.remove();
                }
              }
            }
          }
      ],
    },
}

Excellent job!It works for me!

a screenshot is not a reproduction

would you be able to provide repo which is public? is better other people are able to give feedback on your issue