forked from marsmith/go2mapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
106 lines (98 loc) · 3.18 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
96
97
98
99
100
101
102
103
104
105
106
//webpack info and links
// https://github.com/petehunt/webpack-howto
var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var merge = require('webpack-merge');
var pkg = require('./package.json');
var PATHS = {
src: path.join(__dirname, 'src/'),
dist: path.join(__dirname, 'dist/')
};
var common = {
entry: {
app: PATHS.src + 'scripts/app.js',
vendor: [
'leaflet/dist/leaflet.css',
'bootstrap/dist/css/bootstrap.css',
PATHS.src + '/styles/main.css',
'leaflet',
'esri-leaflet',
'jquery',
// 'jquery/src/core',
// 'jquery/src/ajax',
// 'jquery/src/ajax/xhr',
'bootstrap',
// 'bootstrap/js/modal',
// 'bootstrap/js/collapse',
// 'bootstrap/js/transition',
// 'bootstrap/js/tab',
'highcharts',
'moment',
'@turf/convex'
]
},
output: {
filename: 'bundle.min.js'
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.png$/, loader: 'url-loader?limit=8192', query: { mimetype: 'image/png' } },
{ test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/, loader: 'url-loader' },
{ test: /\.js?$/, exclude: /node_modules/, loader: 'babel-loader' },
{ test: /\.html$/, loader: 'raw-loader' }
]
},
plugins: [
new webpack.ProvidePlugin({
'$': 'jquery',
'jQuery': 'jquery',
'Highcharts': 'highcharts',
'moment': 'moment',
'convex': '@turf/convex',
'L.esri': 'esri-leaflet'
}),
new webpack.DefinePlugin( {'VERSION': JSON.stringify(pkg.version) }),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/)
]
};
var config;
// Detect how npm is run and branch based on that
switch(process.env.npm_lifecycle_event) {
case 'build':
config = merge(common, {
output: {
path: PATHS.dist + 'scripts/',
},
plugins: [
new webpack.optimize.UglifyJsPlugin({compress: { warnings: false }}),
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
new CopyWebpackPlugin([{ from: PATHS.src, to: PATHS.dist, ignore: ['app.js', 'fonts/**/*', 'styles/**/*']} ]),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.min.js'),
]
}
);
break;
default:
config = merge( common, {
output: {
path: PATHS.src + 'scripts/',
},
plugins: [
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development') }),
new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.min.js'),
],
devtool: 'eval-source-map',
devServer: {
// hot: true,
// inline: true,
open: true,
contentBase: PATHS.src,
// host: 'localhost',
// port: 8080
}
}
);
}
module.exports = config;