forked from WhitestormJS/whs.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
100 lines (95 loc) · 2.18 KB
/
webpack.config.babel.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
import path from 'path';
import webpack from 'webpack';
import HappyPack from 'happypack';
import DashboardPlugin from 'webpack-dashboard/plugin';
export function config(
{
isProduction,
src,
dest,
filename = 'whitestorm.js',
plugins = [],
version = require('./package.json').version
}
) {
if (process.env.CI) isProduction = true;
console.log(`Mode: ${isProduction ? 'production' : 'development'}`);
console.log(`Version: ${version}`);
const bannerText = `WhitestormJS Framework v${version}`;
return { // PHYSICS VERSION
devtool: isProduction ? false : 'source-map',
cache: true,
entry: [
`${src}/index.js`
],
target: 'web',
output: {
path: path.join(__dirname, dest),
filename,
library: 'WHS',
libraryTarget: 'umd'
},
module: {
rules: [
{
test: /\.js$/,
exclude: [
/node_modules/
],
loader: 'babel-loader', // babel-loader
query: {
cacheDirectory: true
}
}
]
},
externals: {
three: {
commonjs: 'three',
commonjs2: 'three',
amd: 'three',
root: 'THREE'
}
},
plugins: [
new webpack.LoaderOptionsPlugin({
minimize: isProduction,
debug: !isProduction
}),
...(isProduction ? [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true
},
output: {
comments: false
}
})
] : []),
new HappyPack({loaders: ['babel-loader'], threads: 4}),
new webpack.BannerPlugin(bannerText),
new DashboardPlugin(),
...plugins
],
resolve: {
modules: [
path.resolve(__dirname, 'node_modules'),
src
]
}
};
}
export default config({
isProduction: process.env.NODE_ENV === 'production',
src: './src',
dest: './build'
});