-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwebpack.config.js
81 lines (71 loc) · 2.2 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
var webpack = require('webpack');
var path = require('path');
const ENV = process.env.NODE_ENV;
const BUNDLE_ANALYZER = false;
const LINTER = false;
let config = module.exports = {
entry: {
'app': __dirname + '/src/App.js',
'page': ['jquery', 'd3-quadtree' , 'd3-scale', 'd3-timer', 'jBox', 'jBox/Source/jBox.css', 'date-fns/difference_in_hours', 'pikaday', 'pikaday/css/pikaday.css', __dirname + '/fonts/icomoon.css'],
'map': ['leaflet', 'proj4', 'leaflet-geometryutil', 'leaflet/dist/leaflet.css']
},
devtool: 'source-map',
output: {
path: __dirname+'/dist/',
publicPath: '/dist/',
filename: '[name].bundle.js'
},
plugins: [
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.CommonsChunkPlugin({
names: ['page', 'map']
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest'
}),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/),
],
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
},
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&mimetype=application/font-woff" },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" },
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.jsx?$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.png$/, loader: 'url-loader' }
]
}
};
if (ENV === 'development'){
config.output.sourceMapFilename = '[name].bundle.map';
}
if (ENV === 'production'){
config.plugins.push(
new webpack.optimize.UglifyJsPlugin()
);
}
if (BUNDLE_ANALYZER) {
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
config.plugins.push(
new BundleAnalyzerPlugin()
);
}
if (LINTER) {
config.module.rules.push({
enforce: "pre",
test: /\.js$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {
failOnWarning: false,
failOnError: false,
outputReport: {
filePath: 'checkstyle.xml',
formatter: require('eslint/lib/formatters/checkstyle')
}
},
});
}