Created
July 7, 2017 17:04
-
-
Save JesusMurF/82ee5737990714dc43a7ee37076eb351 to your computer and use it in GitHub Desktop.
Webpack 3
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 webpack = require('webpack') | |
const path = require('path') | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({ | |
template: path.join(__dirname, './src/index.html'), | |
filename: 'index.html', | |
inject: 'body' | |
}) | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
publicPath: '/', | |
filename: 'bundle.js' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.jsx?$/, | |
exclude: /(node_modules|bower_components)/, | |
loader: 'babel-loader' | |
}, | |
{ | |
test: /\.js?$/, | |
exclude: /(node_modules|bower_components)/, | |
loader: 'babel-loader' | |
}, | |
// CSS loader con CSS Modules | |
{ | |
test: /\.css$/, | |
use: [ | |
'style-loader', | |
{ | |
loader: 'css-loader', | |
options: { | |
modules: true | |
} | |
} | |
] | |
}, | |
// Stylus loader con CSS Modules | |
{ | |
test: /\.styl$/, | |
use: [ | |
'style-loader', | |
{ | |
loader: 'css-loader', | |
options: { | |
modules: true, | |
localIdentName: '[name]__[local]___[hash:base64:5]' | |
} | |
}, | |
'stylus-loader' | |
] | |
} | |
] | |
}, | |
devServer: { | |
contentBase: path.join(__dirname, 'dist'), | |
compress: true, | |
hot: true, | |
inline: true, | |
historyApiFallback: true, | |
port: 9000 | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.NoEmitOnErrorsPlugin(), | |
HtmlWebpackPluginConfig | |
] | |
} |
Thanks so much! Any way to use the default CSS identifiers instead of [name]__[local]___[hash:base64:5]
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the gist, very clarifying about getting stylus & css modules working with Webpack3. 🍻