我想知道在添加对SASS(create-react-app
)的支持后如何正确配置webpack(npm install sass-loader node-sass --save-dev
)以进行生产部署。
开发配置工作正常但是一旦我运行npm build
,构建就失败了。
相关摘要:
webpack.config.dev.js
loaders: [
{
exclude: [
/\.html$/,
/\.(js|jsx)$/,
/\.css$/,
/\.json$/,
/\.svg$/,
/\.scss$/
],
loader: 'url',
query: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]'
}
},
{
test: /\.css$/,
loader: 'style!css?importLoaders=1!postcss'
},
{
test: /\.scss$/,
include: paths.appSrc,
loaders: ["style", "css", "sass"]
}
]
webpack.config.prod.js
loaders: [
{
exclude: [
/\.html$/,
/\.(js|jsx)$/,
/\.css$/,
/\.json$/,
/\.svg$/,
/\.scss$/
],
loader: 'url',
query: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]'
}
},
{
test: /\.(scss|sass)$/,
include: paths.appSrc,
loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1!postcss')
}
]