一、安装
-
1、安装
loader
install sass-loader node-sass --save-dev
二、配置
- 1、找到
node_modules/react-scripts/config/webpack.config.dev.js
文件和webpack.config.prod.js
- 2、新增圈住的地方
{
loader: require.resolve('file-loader'),
// Exclude `js` files to keep "css" loader working as it injects
// it's runtime that would otherwise processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.js$/, /\.html$/, /\.json$/,/\.scss$/],
options: {
name: 'static/media/[name].[hash:8].[ext]',
},
},
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader'],
}