我正在将Material UI集成到Svelte项目中。
我遵循documentation中的所有内容,但是在运行项目时遇到此错误:
!] (plugin postcss) Error: File to import not found or unreadable: smui-theme.
node_modules/@smui/tab/_index.scss
Error: File to import not found or unreadable: smui-theme.
可能是什么问题?
该错误意味着您必须具有一个名为_smui-theme.scss
的文件才能编译Sass。
首先请确保您的项目中_smui-theme.scss
目录下有文件theme
。(我通常将其放在src/theme/_smui-theme.scss
中)
然后您必须将其添加到汇总插件的postcss
配置中,如下所示:
import postcss from 'rollup-plugin-postcss';
export default {
...
plugins: [
svelte({
...
}),
....
postcss({
extract: true,
minimize: true,
use: [
['sass', {
includePaths: [
'./src/theme', <<< ------------ HERE
'./node_modules'
]
}]
]
}),
...
};
请确保theme
目录已正确包含在postcss
插件配置中,如前所示。
注意:如果路径不正确,您可能会收到相同的错误!