forked from sidx1024/deck.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
119 lines (100 loc) · 2.28 KB
/
webpack.config.js
File metadata and controls
119 lines (100 loc) · 2.28 KB
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
const {resolve} = require('path');
const webpack = require('webpack');
const LIBRARY_BUNDLE_CONFIG = {
// Bundle the source code
entry: {
lib: resolve('./src/index.js')
},
// Silence warnings about big bundles
stats: {
warnings: false
},
output: {
// Generate the bundle in dist folder
path: resolve('./dist'),
filename: '[name]-bundle.js',
library: 'deck.gl',
libraryTarget: 'umd'
},
// Exclude any non-relative imports from resulting bundle
externals: [
/^[a-z\.\-0-9]+$/
],
module: {
rules: [
{
// Inline shaders
test: /\.glsl$/,
exclude: /node_modules/,
loader(content) {
this.cacheable && this.cacheable(); // eslint-disable-line
this.value = content;
return "module.exports = " + JSON.stringify(content); // eslint-disable-line
}
}
]
},
node: {
fs: 'empty'
},
plugins: [
// leave minification to app
// new webpack.optimize.UglifyJsPlugin({comments: false})
new webpack.DefinePlugin({
DECK_VERSION: JSON.stringify(require('./package.json').version)
})
]
};
const TEST_BROWSER_CONFIG = {
devServer: {
stats: {
warnings: false
},
quiet: true
},
// Bundle the tests for running in the browser
entry: {
'test-browser': resolve('./test/browser.js')
},
// Generate a bundle in dist folder
output: {
path: resolve('./dist'),
filename: '[name]-bundle.js'
},
devtool: '#inline-source-maps',
resolve: {
alias: {
'deck.gl/test': resolve('./test'),
'deck.gl/dist': resolve('./src'),
'deck.gl': resolve('./src'),
'deck.gl-layers': resolve('./src/experimental-layers/src'),
'@deck.gl/test-utils': resolve('./src/test-utils/src')
}
},
module: {
rules: []
},
node: {
fs: 'empty'
},
plugins: []
};
const BENCH_BROWSER_CONFIG = Object.assign({}, TEST_BROWSER_CONFIG, {
entry: {
'test-browser': resolve('./test/bench/browser.js')
}
});
// Replace the entry point for webpack-dev-server
BENCH_BROWSER_CONFIG.module.noParse = [
/benchmark/
];
module.exports = env => {
env = env || {};
if (env.bench) {
return BENCH_BROWSER_CONFIG;
}
if (env.test) {
return TEST_BROWSER_CONFIG;
}
return LIBRARY_BUNDLE_CONFIG;
};