Skip to content

Commit 31fb0dd

Browse files
author
Sonic Xiang
committed
Add sass
1 parent bf77022 commit 31fb0dd

File tree

4 files changed

+1549
-2
lines changed

4 files changed

+1549
-2
lines changed

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ module.exports = {
213213
},
214214
],
215215
},
216+
//-------------------- Add SCSS Loaders -------------------------//
217+
{
218+
test: /\.scss$/,
219+
loaders: [
220+
require.resolve('style-loader'),
221+
require.resolve('css-loader'),
222+
require.resolve('sass-loader')
223+
]
224+
},
216225
// "file" loader makes sure those assets get served by WebpackDevServer.
217226
// When you `import` an asset, you get its (virtual) filename.
218227
// In production, they would get copied to the `build` folder.
@@ -223,7 +232,7 @@ module.exports = {
223232
// its runtime that would otherwise processed through "file" loader.
224233
// Also exclude `html` and `json` extensions so they get processed
225234
// by webpacks internal loaders.
226-
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
235+
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /\.scss$/],
227236
loader: require.resolve('file-loader'),
228237
options: {
229238
name: 'static/media/[name].[hash:8].[ext]',

packages/react-scripts/config/webpack.config.prod.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ module.exports = {
242242
),
243243
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
244244
},
245+
//-------------------- Add SCSS Loaders -------------------------//
246+
{
247+
test: /\.scss$/,
248+
loaders: [
249+
require.resolve('style-loader'),
250+
require.resolve('css-loader'),
251+
require.resolve('sass-loader')
252+
]
253+
},
245254
// "file" loader makes sure assets end up in the `build` folder.
246255
// When you `import` an asset, you get its filename.
247256
// This loader doesn't use a "test" so it will catch all modules
@@ -252,7 +261,7 @@ module.exports = {
252261
// it's runtime that would otherwise processed through "file" loader.
253262
// Also exclude `html` and `json` extensions so they get processed
254263
// by webpacks internal loaders.
255-
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
264+
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /\.scss$/],
256265
options: {
257266
name: 'static/media/[name].[hash:8].[ext]',
258267
},

0 commit comments

Comments
 (0)