方法一:
在
vite.conifg.ts中的css節(jié)點(diǎn)增加
// 忽略scss字符集,報(bào)錯(cuò): @charset" must be the first rule in the file
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove()
}
}
}
}
]
}
方法二:
在根目錄下創(chuàng)建
postcss.config.js
module.exports = {
plugins: [
// 移除打包element時(shí)的@charset警告
// 忽略element的scss字符集,報(bào)錯(cuò): @charset" must be the first rule in the file
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule) => {
if (atRule.name === 'charset') {
atRule.remove()
}
}
}
}
]
}