赞
踩
@charset:UTF-8
;@charset:UTF-8
。在组合css时@charset的位置并不是在头部(或最前面),同时本地scss如果有中文也会自动添加@charset:UTF-8
。因此build时就会warning提示错误了。
修改vite.config.js,添加charset:false
禁止项目scss添加@charset:UTF-8
。
同时配置postcss删除库里的@charset:UTF-8
- export default defineConfig({
- css: {
- preprocessorOptions: {
- scss: {
- charset: false
- }
- },
- postcss: {
- plugins: [
- {
- postcssPlugin: 'internal:charset-removal',
- AtRule: {
- charset: (atRule) => {
- if (atRule.name === 'charset') {
- atRule.remove();
- }
- }
- }
- }
- ],
- },
- },
- })

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。