-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
72 lines (68 loc) · 1.76 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
var webpack = require('webpack');
var path = require('path');
module.exports = function(env) {
var debug = false;
if(env) {
debug = !!env.debug;
}
var commonPlugins = [
new webpack.DefinePlugin({
GLOBAL_LIBS: {
jQuery: JSON.stringify(true),
html2canvas: JSON.stringify(true),
React: JSON.stringify(true),
THREE: JSON.stringify(true),
PDFJS: JSON.stringify(true),// don't set false. It isn't implemented
},
GLOBAL_PATHS: {
pdfJsWorker: JSON.stringify('js/pdf.worker.js'),
pdfJsCMapUrl: JSON.stringify('cmaps/')
}
})
];
if(!debug) {
commonPlugins.push(new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}));
}
return {
context: __dirname,
devtool: debug ? 'inline-sourcemap' : '',
entry: ['../common/polyfill.js', './index.js'],
output: {
path: __dirname,
filename: 'js/dist/'+(debug? '3dflipbook.js': '3dflipbook.min.js')
},
module: {
loaders: [
{
test: /\.html$/,
loader: 'raw-loader'
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: [['es2015', {'loose': true}], 'stage-0'],
plugins: ['transform-class-properties']
}
}
]
},
resolve: {
extensions: ['.js'],
modules: [
path.resolve('./node_modules'),
path.resolve('../common/classes')
]
},
plugins: debug ? commonPlugins : [
...commonPlugins,
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
],
};
}