forked from makehuman-js/makehuman-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
93 lines (84 loc) · 2.44 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
const path = require('path')
const webpack = require('webpack')
const BUILD_DEV = !(process.env.NODE_ENV === "production")
const OUTPUTDIR = 'dist'
const SRC_PATH = path.join(__dirname, './src')
console.log(`Running in BUILD_DEV=${BUILD_DEV} mode to OUTPUTDIR=${OUTPUTDIR}`)
// ///////////
// Plugins //
// ///////////
// uglify in production
const uglifyJsPlugin = new webpack.optimize.UglifyJsPlugin({
minimize: !BUILD_DEV,
sourceMap: BUILD_DEV,
mangle: false,
output: {
},
compress: {
// drop_debugger: true,
drop_console: !BUILD_DEV,
// warnings: false,
unused: true,
dead_code: true
}
})
const plugins = [
]
if (BUILD_DEV) {
// DEVELOPMENT
plugins.push(
)
} else {
console.warn('!!!!! RELEASE BUILD !!!!!\n')
plugins.push(
// Disable due to issue with this plugin
// See https://github.com/webpack/webpack/issues/2644
// new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
uglifyJsPlugin,
new webpack.NoErrorsPlugin()
)
}
// main config
module.exports = {
entry: {makehuman:'./src/bundle.js'},
output: {
path: path.join(__dirname, OUTPUTDIR),
filename: BUILD_DEV ? '[name].js' : '[name].min.js',
libraryTarget: 'umd',
library: '[name]'
},
module: {
loaders: [
{
test: /\.js$/i,
// loaders: ['react-hot',{loader:'babel', query:{cacheDirectory: true}}],
// Note: you need a the .babelrc file to solve http://stackoverflow.com/questions/32211649/debugging-with-webpack-es6-and-babel
loader: 'babel',
exclude: /(node_modules|bower_components)/,
query: {
cacheDirectory: 'node_modules/.cache'
}
},
// this loads it as javascript in one go
{
test: /\.json$/,
loader: 'json-loader'
},
]
},
resolve: {
modules: [
SRC_PATH,
'./src/js',
'./test',
'./test/mocha',
"node_modules",
],
// extentions to auto add if needed
extensions: ["", ".js"]
},
devtool: BUILD_DEV ? 'source-map' : 'cheap-module-source-map', // slower than 'cheap-module-eval-source-map'
plugins
}