-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
96 lines (92 loc) · 2.43 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
var path = require('path');
var webpack = require('webpack');
// var sharedJQueryPath = require.resolve('jquery');
module.exports = [{
mode: 'development',
entry: [
// 'babel-polyfill',
'whatwg-fetch',
"array.prototype.fill",
'./source/js/diva.js'
],
output: {
path: path.join(__dirname, 'static', 'js'),
filename: 'diva.js'
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.json$/,
loaders: ['json']
},
{
loader: "babel-loader",
// include: [
// path.resolve(__dirname, "source/js")
// ],
query: {
presets: ["es2015"],
}
}
]
},
plugins: (process.env.NODE_ENV === "production") ? productionPlugins() : developmentPlugins()
}, {
entry: {
'pixel': './source/js/plugins/pixel.js/source/pixel.js',
'download': './source/js/plugins/download.js',
'manipulation': './source/js/plugins/manipulation.js'
},
output: {
path: path.join(__dirname, 'static', 'js'),
filename: '[name].js'
},
resolve: {
extensions: ["*", ".js"],
},
module: {
rules: [
{
loader: "babel-loader",
include: [
path.resolve(__dirname, "source/js/plugins")
],
query: {
presets: ["es2015"]
}
}
]
}
}];
function productionPlugins()
{
return [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(true),
new webpack.ProvidePlugin({
// 'diva': 'diva',
// '$': sharedJQueryPath,
// 'jQuery': sharedJQueryPath,
// 'window.jQuery': sharedJQueryPath,
// URLSearchParams: "url-search-params"
})
]
}
function developmentPlugins()
{
return [
new webpack.ProvidePlugin({
// 'diva': 'diva',
// '$': sharedJQueryPath,
// 'jQuery': sharedJQueryPath,
// 'window.jQuery': sharedJQueryPath,
// URLSearchParams: "url-search-params"
})
]
}