forked from cloud-gov/pages-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
70 lines (66 loc) · 1.86 KB
/
webpack.config.babel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import path from 'path';
import webpack from 'webpack';
import autoprefixer from 'autoprefixer';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import ManifestPlugin from 'webpack-manifest-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
const extractStyles = new ExtractTextPlugin({
filename: 'styles/styles.[contenthash].css',
allChunks: true,
});
const manifestPlugin = new ManifestPlugin({
fileName: '../webpack-manifest.json',
});
export default {
entry: './frontend/main.jsx',
devtool: 'source-map',
output: {
filename: 'js/bundle.[hash].js',
path: path.resolve(__dirname, 'public'),
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components|public\/)/,
loader: 'babel-loader',
},
{
test: /\.scss$/,
use: extractStyles.extract([
'css-loader?sourceMap',
{
loader: 'postcss-loader',
options: {
sourceMap: true,
plugins: [autoprefixer],
},
},
'sass-loader?sourceMap',
]),
},
{
test: /\.(gif|png|jpe?g|svg|ttf|woff2?|eot)$/i,
loader: 'file-loader?name=/styles/webpackAssets/[hash].[ext]',
},
],
},
plugins: [
extractStyles,
manifestPlugin,
// When webpack bundles moment, it includes all of its locale files,
// which we don't need, so we'll use this plugin to keep them out of the
// bundle
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
// Generate a webpack-bundle-analyzer stats file (in public/stats.json)
// It can be viewed by running `yarn analyze-webpack`
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
openAnalyzer: false,
generateStatsFile: true,
}),
],
};