forked from visgl/luma.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
77 lines (67 loc) · 1.7 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
/* eslint-disable import/no-extraneous-dependencies */
const {getWebpackConfig} = require('ocular-dev-tools');
module.exports = (env = {}) => {
let config = getWebpackConfig(env);
config.devtool = 'source-map';
config = addBabelSettings(config);
switch (env.mode) {
case 'perf':
config.entry = {
perf: './test/perf/index.js'
};
break;
default:
}
// Log regex
// eslint-disable-next-line
Object.defineProperty(RegExp.prototype, 'toJSON', {
value: RegExp.prototype.toString
});
// Uncomment to debug config
// console.warn(JSON.stringify(config, null, 2));
return [config];
};
function makeBabelRule() {
return {
// Compile source using babel
test: /(\.js|\.ts|\.tsx)$/,
loader: 'babel-loader',
include: [/modules\/.*\/src/, /modules\/.*\/test/, /examples/, /test/],
exclude: [/node_modules/],
options: {
presets: [
'@babel/preset-react',
'@babel/preset-typescript',
[
'@babel/preset-env',
{
exclude: [/transform-async-to-generator/, /transform-regenerator/]
}
]
],
plugins: ['@babel/plugin-proposal-class-properties']
}
};
}
function addBabelSettings(config) {
return {
...config,
module: {
...config.module,
rules: [
...config.module.rules.filter(r => r.loader !== 'babel-loader'),
makeBabelRule(),
// See https://github.com/apollographql/apollo-link-state/issues/302
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
}
]
},
resolve: {
...config.resolve,
extensions: ['.ts', '.tsx', '.js', '.json']
}
};
}