Created
May 30, 2020 21:36
-
-
Save bjackson/0216081965babd482448c42961798b2e to your computer and use it in GitHub Desktop.
SCSS Modules in Redwood
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
module.exports = (config) => { | |
const isDevelopment = process.env.NODE_ENV !== 'production'; | |
config.plugins.push(new MiniCssExtractPlugin({ | |
filename: isDevelopment ? '[name].css' : '[name].[hash].css', | |
chunkFilename: isDevelopment ? '[id].css' : '[id].[hash].css', | |
})); | |
config.module.rules[0].oneOf.unshift({ | |
test: /\.module\.scss$/i, | |
loader: [ | |
isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader, | |
{ | |
loader: 'css-loader', | |
options: { | |
modules: true, | |
sourceMap: isDevelopment | |
} | |
}, | |
{ | |
loader: 'sass-loader', | |
options: { | |
sourceMap: isDevelopment | |
} | |
} | |
] | |
}); | |
config.resolve.extensions.push('.scss'); | |
return config; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment