Skip to content

Instantly share code, notes, and snippets.

@0xAnon101
Last active September 27, 2018 12:00
Show Gist options
  • Save 0xAnon101/5f405c5dfd3ef3eec36dc7baf03a378b to your computer and use it in GitHub Desktop.
Save 0xAnon101/5f405c5dfd3ef3eec36dc7baf03a378b to your computer and use it in GitHub Desktop.
css / sass modules in webpack configuration
const HtmlWebPackPlugin = require('html-webpack-plugin');
const htmlPlugin = new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html"
})
module.exports = (env,argv) => {
return {
optimization: {
nodeEnv: argv.mode
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.(sa|sc|c)ss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: "[name]_[local]_[hash:base64:5]",
}
},
'sass-loader'
]
}
]
},
plugins: [htmlPlugin]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment