-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.rules.js
41 lines (38 loc) · 1.18 KB
/
webpack.rules.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
const isProd = process.env.NODE_ENV === 'production';
module.exports = [];
// Native modules are weirdly handled :
// When in dev mode, using webpack-asset-relocator-loader create a relative path that seems to be wrong
// But node-loader overwrite this relative path to an absolute path (absolute to dev path... it won't work on production)
// However, on production (when making zip, and other packages) the relative path generated by webpack-asset-relocator work properly
// So we only enable node-loader when in dev mode (the NODE_ENV var is set to "production" in package.json scripts)
!isProd && module.exports.push({
test: /\.node$/,
use: 'node-loader',
});
module.exports.push({
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@marshallofsound/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
debugLog: true,
},
},
},
{
test: /\.tsx?$/,
exclude: /(node_modules|.webpack)/,
loaders: [{
loader: 'ts-loader',
options: {
transpileOnly: true,
},
}],
},
{
test: /\.jsx?$/,
exclude: /(node_modules|.webpack)/,
use: 'babel-loader',
},
);