在文件路径没有问题时,引入scss出现错误
-
ERROR Failed to compile with 1 errors 15:04:40
-
This relative module was not found:
-
* ./assets/css/style.scss in ./src/main.js
主要原因是新版本的vue-cli
已经帮我们把sass-loader
配置好了,放在了util.js
里面。
原来我们需要在webpack.base.config.js
中去配置以下这段代码:
-
{
-
test: /\.scss$/,
-
use: [
-
{
-
loader: 'style-loader' // creates style nodes from JS strings
-
},
-
{
-
loader: 'css-loader' // translates CSS into CommonJS
-
},
-
{
-
loader: 'sass-loader' // compiles Sass to CSS
-
}
-
]
-
}
现在不需要这样配置。如果这样配置会报错,因为配置重复了。
所以,只需要安装相应的loader
,比如使用sass
需要安装node-sass
、sass-loader
。