Skip to content

Instantly share code, notes, and snippets.

@zaidaldabbagh
Last active November 13, 2018 20:32
Show Gist options
  • Save zaidaldabbagh/168c942590364c56fef8e15f08312802 to your computer and use it in GitHub Desktop.
Save zaidaldabbagh/168c942590364c56fef8e15f08312802 to your computer and use it in GitHub Desktop.
Example webpack.config.js for webpack setup — See zaidaldabbagh.com/blog/webpack-setup
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const devMode = process.env.NODE_ENV !== 'production'
module.exports = {
entry: ['./js/index.js', './scss/style.scss'],
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: devMode ? 'bundle.css' : 'bundle.[hash].css',
chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
})
],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader'
]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: [
'file-loader'
]
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment