-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
68 lines (64 loc) · 2.05 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
const path = require('path');
const { env } = require('process');
module.exports = (env, argv) => {
// This function creates an object which is then used in the webpack config
// when the env variable "use_local_chainjs_code_NOT_npm" is set,
// webpack will look to get it's source code from ../chain-js/dist/src
// becasue ts-loader has options: {projectReferences: true} set,
// it will rebuild the chainjs source and output to ../chain-js/dist/src before webpack creates the final bundle
var local_chainjs_alias = function() {
if(env.use_local_chainjs_code_NOT_npm == 'true') {
return {
"@open-rights-exchange/chain-js": path.resolve(__dirname, "../chain-js/dist/src"),
"@open-rights-exchange/chain-js-plugin-eos": path.resolve(__dirname, "../chain-js-plugin-eos/dist/src"),
"@open-rights-exchange/chain-js-plugin-ethereum": path.resolve(__dirname, "../chain-js-plugin-ethereum/dist/src"),
"@open-rights-exchange/chain-js-plugin-algorand": path.resolve(__dirname, "../chain-js-plugin-algorand/dist/src")
}
} else {
return {}
}
}();
var local_chainjs_alias_projectReferences = function() {
if(env.use_local_chainjs_code_NOT_npm == 'true') {
return true
} else {
return false
}
}();
return {entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: [{
loader:'ts-loader',
options: {projectReferences: local_chainjs_alias_projectReferences}
}],
exclude: [
/node_modules/
],
},
{
test: /\.js$/,
enforce: "pre",
use: ["source-map-loader"],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: local_chainjs_alias,
fallback: {
"electron": false,
},
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
devtoolModuleFilenameTemplate: '[absolute-resource-path]'
},
devtool: 'cheap-module-source-map',
target: ["node"],
mode: 'development'
}
};