Skip to content

Commit

Permalink
Add sass
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonic Xiang committed Aug 29, 2018
1 parent bf77022 commit 31fb0dd
Show file tree
Hide file tree
Showing 4 changed files with 1,549 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/react-scripts/config/webpack.config.dev.js
Expand Up @@ -213,6 +213,15 @@ module.exports = {
},
],
},
//-------------------- Add SCSS Loaders -------------------------//
{
test: /\.scss$/,
loaders: [
require.resolve('style-loader'),
require.resolve('css-loader'),
require.resolve('sass-loader')
]
},
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
// In production, they would get copied to the `build` folder.
Expand All @@ -223,7 +232,7 @@ module.exports = {
// its runtime that would otherwise processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /\.scss$/],
loader: require.resolve('file-loader'),
options: {
name: 'static/media/[name].[hash:8].[ext]',
Expand Down
11 changes: 10 additions & 1 deletion packages/react-scripts/config/webpack.config.prod.js
Expand Up @@ -242,6 +242,15 @@ module.exports = {
),
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
},
//-------------------- Add SCSS Loaders -------------------------//
{
test: /\.scss$/,
loaders: [
require.resolve('style-loader'),
require.resolve('css-loader'),
require.resolve('sass-loader')
]
},
// "file" loader makes sure assets end up in the `build` folder.
// When you `import` an asset, you get its filename.
// This loader doesn't use a "test" so it will catch all modules
Expand All @@ -252,7 +261,7 @@ module.exports = {
// 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|jsx|mjs)$/, /\.html$/, /\.json$/],
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /\.scss$/],
options: {
name: 'static/media/[name].[hash:8].[ext]',
},
Expand Down

0 comments on commit 31fb0dd

Please sign in to comment.