如何在TSDX中引用css样式文件?
TSDX默认不支持引入css,遇到 import xxx.css
会提示:
✖ Failed to compile
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
解决方法
在项目根目录,新建tsdx.config.js
:
const postcss = require('rollup-plugin-postcss');
module.exports = {
rollup(config, options) {
config.plugins.push(
postcss({
inject: false,
extract: !!options.writeMeta,
}),
);
return config;
},
};
并安装