-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathplugins.js
More file actions
29 lines (25 loc) · 658 Bytes
/
plugins.js
File metadata and controls
29 lines (25 loc) · 658 Bytes
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
const { readFileSync } = require('fs');
const envPlugin = {
name: 'env',
setup(build) {
build.onResolve({ filter: /@app\/env$/ }, (args) => {
return {
path: args.path,
namespace: 'env-ns',
};
});
build.onLoad({ filter: /.*/, namespace: 'env-ns' }, () => {
const envFile = process.env.NODE_ENV ? `.${process.env.NODE_ENV}` : '';
const content = readFileSync(
`../../environments/environment${envFile}.ts`,
'utf8'
);
return {
contents: content,
resolveDir: '../../environments',
loader: 'ts',
};
});
},
};
module.exports = [envPlugin];