出於某種原因,我yarn run dev
命令到後續失敗的原因:意外標記 - 的WebPack 2.2.0和SCSS
SyntaxError: /src/components/home/index.scss:Unexpected token (1:0)
> 1 | .home {
...
我使用的WebPack 2.2.0這是設置像這樣:
module: {
rules: [
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
include: path.resolve(__dirname, 'src'),
}, {
test: /\.(scss)/,
include: path.resolve(__dirname, 'src'),
use: [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]',
'sass-loader',
{
loader: 'postcss-loader',
options: {
plugins: function() {
return [
require('autoprefixer')
]
}
}
}
],
include: path.resolve(__dirname, 'src')
}
]
}
而我在我的index.js組件中做的全部是import s from './styles.scss'
。如果我刪除import
語句並允許應用程序啓動,然後在應用程序運行時將import
語句重新插入並刷新頁面,則樣式存在...我覺得這非常奇怪,並且以前沒有遇到此問題...
守ldn't'sass-loader'來到loader數組的末尾? –