【发布时间】:2020-06-30 19:04:34
【问题描述】:
我正在使用 Svelte 和材料设计库 Svelte Material UI 开展一个项目。
这个材料设计库需要SASS,所以我用npm install svelte-preprocess安装了一个预处理器,并在rollup.config.js中添加了preprocess: autoPreprocess()。所以我现在有:
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file - better for performance
css: css => {
css.write('public/build/bundle.css');
},
preprocess: autoPreprocess()
}),
routify({ singleBuild : true}),
replace({
// stringify the object
APPENV: JSON.stringify({
isProd: production,
...config().parsed // attached the .env config
}),
}),
// more stuff
]
我有一个文件smui.js,内容如下:
import Button from '@smui/button';
import Checkbox from '@smui/checkbox';
import Chips from '@smui/chips';
import Dialog from '@smui/dialog';
import FormField from '@smui/form-field';
import Select from '@smui/select';
export {
Button,
Checkbox,
Chips,
Dialog,
FormField,
Select
}
在我的index.svelte 文件中,我以这种方式导入上述内容:import * as Smui from "../smui.js";。
我得到的不是应用程序应该运行的端口的成功消息:
[!] Error: Unexpected character '@' (Note that you need plugins to import files that are not JavaScript)
node_modules\@smui\dialog\_index.scss (1:0)
1: @import "smui-theme";
^
2: @import "./style";
Error: Unexpected character '@' (Note that you need plugins to import files that are not JavaScript)
我做错了什么?
【问题讨论】:
-
如何在 Svelte 组件中包含 sass?
标签: javascript svelte svelte-3