Skip to content

Instantly share code, notes, and snippets.

@astrotim
Created March 7, 2017 10:55
Show Gist options
  • Save astrotim/61993194e1b7cba299b1e9b5463f3d3f to your computer and use it in GitHub Desktop.
Save astrotim/61993194e1b7cba299b1e9b5463f3d3f to your computer and use it in GitHub Desktop.
Working CSS Modules Webpack config
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: [
path.resolve(__dirname, 'src')
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
plugins: [
new ExtractTextPlugin('style.css')
],
module: {
rules: [
{
test: /\.js$/,
exclude: [path.resolve(__dirname, 'node_modules')],
use: {
loader: 'babel-loader',
options: {
presets: ['es2015']
}
}
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: {
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]'
}
}
})
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment