removeddit/webpack.common.js

75 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-01-09 01:15:49 +00:00
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
2018-01-09 01:15:49 +00:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
2018-01-10 19:08:41 +00:00
const extractSass = new ExtractTextPlugin({
2018-01-16 00:12:14 +00:00
filename: 'bundle.[contenthash].css',
2018-01-10 19:08:41 +00:00
});
2018-01-09 01:15:49 +00:00
module.exports = {
2018-01-16 00:12:14 +00:00
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,
},
}