Last active
November 13, 2018 20:32
-
-
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
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 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