removeddit/webpack.common.js
2018-01-10 21:13:15 +01:00

75 lines
No EOL
1.3 KiB
JavaScript

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractSass = new ExtractTextPlugin({
filename: 'bundle.[contenthash].css',
});
module.exports = {
entry: [
'@babel/polyfill',
'whatwg-fetch',
'./src/js/index.js',
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.[chunkhash].js',
publicPath: '/'
},
resolve: {
modules: [
path.resolve('./src/js'),
path.resolve('./node_modules')
]
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}
]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.sass$/,
loader: extractSass.extract({
use: ['css-loader','sass-loader']
})
}
]
},
plugins: [
new CleanWebpackPlugin(['dist']),
extractSass,
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new CopyWebpackPlugin([
{
from: 'src/404.html',
to: '404.html'
},
{
from: 'src/images',
to: 'images/'
}
]),
],
stats: {
colors: true
},
}