Created
March 7, 2017 10:55
-
-
Save astrotim/61993194e1b7cba299b1e9b5463f3d3f to your computer and use it in GitHub Desktop.
Working CSS Modules Webpack config
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 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