forked from stephomi/sculptgl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
62 lines (55 loc) · 1.29 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
var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');
module.exports = function (env) {
env = env || {};
var config = {
entry: './main.js',
output: {
library: 'sculptgl',
libraryTarget: 'umd',
path: path.resolve(__dirname, 'app'),
filename: 'sculptgl.js'
},
resolve: {
modules: [
path.join(__dirname, 'src'),
path.join(__dirname, 'lib'),
path.join(__dirname, 'node_modules')
]
},
module: {
rules: [{
test: /\.glsl$/,
loader: 'raw-loader'
}]
},
plugins: []
};
config.mode = (env.release || env.website) ? 'production' : 'development';
var indexFile;
if (env.release) {
indexFile = 'tools/index.release.html';
} else if (env.website) {
indexFile = 'tools/index.website.html';
} else {
indexFile = 'tools/index.dev.html';
}
config.plugins.push(new CopyWebpackPlugin({
patterns: [
{ from: 'tools/authSuccess.html', to: 'authSuccess.html' },
{ from: indexFile, to: 'index.html' }
],
}));
if (env.release) {
config.module.rules.push({
test: /\.js$/,
use: [{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}]
});
}
return config;
};