-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
95 lines (87 loc) · 2.64 KB
/
webpack.config.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
'use strict';
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HOT_RELOADING = !!process.env.HOT_RELOADING;
const VENDOR_LIBS = [
'immutable', 'material-ui',
'react', 'react-dom', 'react-keydown', 'react-redux', 'react-router-dom',
'redux', 'redux-actions', 'redux-promise-middleware', 'redux-thunk',
'reselect'
//, 'react-jsonschema-form' // do not put this module as it has a circular dependency that breaks webpack 3
];
const plugins = [
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
// todo enable when we upgrade to webpack 3
// new webpack.optimize.ModuleConcatenationPlugin()
];
let outputFilename;
if (process.env.NODE_ENV === 'production') {
// const BabiliPlugin = require('babili-webpack-plugin');
// plugins.push(new BabiliPlugin());
outputFilename = '[name].[chunkhash].js';
} else {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
// const CircularDependencyPlugin = require('circular-dependency-plugin');
plugins.push(
new BundleAnalyzerPlugin()
// new CircularDependencyPlugin()
);
if (HOT_RELOADING) {
plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin()
);
}
outputFilename = '[name].[hash].js';
}
module.exports = {
entry: {
bundle: [
'react-hot-loader/patch',
'regenerator-runtime/runtime',
'./src/index.js'
],
vendor: VENDOR_LIBS
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: outputFilename,
publicPath: '/larissa-ui/'
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.js$/,
exclude: /node_modules/
},
{
use: ['style-loader', 'css-loader'],
test: /\.css$/
},
{
use: 'url-loader',
test: /\.(jpe?g|png|gif|svg)$/i
}
],
// todo work around a bug in redux-persist: https://github.com/rt2zz/redux-persist/issues/366
strictThisContextOnImports: true
},
plugins,
devtool: 'source-map',
devServer: {
hot: HOT_RELOADING,
compress: true,
historyApiFallback: true,
contentBase: './'
}
};