-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
webpack.config.js
166 lines (150 loc) · 4.34 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
const path = require('path');
const webpack = require('webpack');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const packg = require("./package.json");
const banner = "MineRender " + packg.version + "\n" +
"(c) 2018, Haylee Schäfer (inventivetalent) / MIT License\n" +
"https://minerender.org\n" +
"Build #" + (process.env.TRAVIS_BUILD_NUMBER || Date.now()) + " / " + new Date().toString()
let baseConfigFull = {
mode: "development",
context: path.resolve(__dirname),
entry: './src/SOME_DIR/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'OUT_NAME.js'
},
externals: {
jquery: 'jQuery',
three: "THREE"
},
plugins: [
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(false),
BUILD_DATE: JSON.stringify(new Date()),
VERSION: JSON.stringify(packg.version),
BUILD_TIMESTAMP: JSON.stringify(Date.now()),
BUILD_NUMBER: JSON.stringify(process.env.TRAVIS_BUILD_NUMBER)
}),
new webpack.BannerPlugin(banner),
new ProgressBarPlugin()
]
};
let baseConfigMin = {
mode: "production",
context: path.resolve(__dirname),
entry: './src/SOME_DIR/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'OUT_NAME.min.js'
},
externals: {
jquery: 'jQuery',
three: "THREE"
},
plugins: [
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(true),
BUILD_DATE: JSON.stringify(new Date()),
VERSION: JSON.stringify(packg.version),
BUILD_TIMESTAMP: JSON.stringify(Date.now()),
BUILD_NUMBER: JSON.stringify(process.env.TRAVIS_BUILD_NUMBER)
}),
new webpack.BannerPlugin(banner)
]
};
////// Actual Configs below
let skinConfig = Object.assign({}, baseConfigMin, {
entry: './src/skin/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'skin.min.js'
},
});
let skinConfigFull = Object.assign({}, baseConfigFull, {
entry: './src/skin/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'skin.js'
},
});
let modelConfig = Object.assign({}, baseConfigMin, {
entry: './src/model/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'model.min.js'
},
});
let modelConfigFull = Object.assign({}, baseConfigFull, {
entry: './src/model/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'model.js'
},
});
let guiConfig = Object.assign({}, baseConfigMin, {
entry: './src/gui/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'gui.min.js'
},
});
let guiConfigFull = Object.assign({}, baseConfigFull, {
entry: './src/gui/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'gui.js'
},
});
let entityConfig = Object.assign({}, baseConfigMin, {
entry: './src/entity/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'entity.min.js'
},
});
let entityConfigFull = Object.assign({}, baseConfigFull, {
entry: './src/entity/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'entity.js'
},
});
let combinedConfig = Object.assign({}, baseConfigMin, {
entry: './src/combined/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'all.min.js'
},
});
let combinedConfigFull = Object.assign({}, baseConfigFull, {
entry: './src/combined/index.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'all.js'
},
});
// Index scripts
let dataConfig = Object.assign({}, baseConfigMin, {
entry: './js/data.js',
output: {
path: path.resolve(__dirname, './js'),
filename: 'data.min.js'
},
});
let mainConfig = Object.assign({}, baseConfigMin, {
entry: './js/main.js',
output: {
path: path.resolve(__dirname, './js'),
filename: 'main.min.js'
},
});
module.exports = [
skinConfig, skinConfigFull,
modelConfig, modelConfigFull,
guiConfig, guiConfigFull,
entityConfig, entityConfigFull,
combinedConfig, combinedConfigFull,
dataConfig,
mainConfig
];