我的网页配置中有以下模块:
module: {
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
loader: 'babel',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.html$/,
loader: 'vue-html'
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
query: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
您可以看到,我正在使用sass loader和for*.scss文件我定义这个管道:['style', 'css', 'sass']
.
然后我有我的scss文件:
html {
height: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
(...)
最后,我有了我的HTML页面(在VUE.js中的一个VUE文件中),该页面导入了该scss文件:
<script>
require('./styles/main.scss')
(...)
</script>
But somehow I get this error when launching the project:
ERROR in ./~/css-loader!./~/sass-loader!./~/style-loader!./~/css-loader!./~/sass-loader!./src/styles/main.scss
Module build failed:
html {
^
Invalid CSS after "...load the styles": expected 1 selector or at-rule, was "var content = requi"
in /Users/td/uprank/src/styles/main.scss (line 1, column 1)
@ ./src/styles/main.scss 4:14-247 13:2-17:4 14:20-253
为什么管道出了问题?(看起来webpack正在try 处理['css', 'sass', 'style', 'css', 'sass']
个,而不是模块中配置的['style', 'css', 'sass']
个.).
我做错了什么?
谢谢
EDIT:链接到完整示例项目:https://dl.dropboxusercontent.com/u/1066659/dummy.zip