generated from maximegris/angular-electron
-
-
Notifications
You must be signed in to change notification settings - Fork 91
/
webpack.config.ts
49 lines (41 loc) · 1.44 KB
/
webpack.config.ts
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
//Polyfill Node.js core modules in Webpack. This module is only needed for webpack 5+.
import {BuildOptions} from "@angular-devkit/build-angular/src/utils/build-options";
import {Configuration, ProvidePlugin} from 'webpack';
/**
* Custom angular webpack configuration
*/
module.exports = (config: Configuration, options: BuildOptions) => {
config.target = 'web';
if (options.fileReplacements) {
for (let fileReplacement of options.fileReplacements) {
if (fileReplacement.replace !== 'src/environments/environment.ts') {
continue;
}
let fileReplacementParts = fileReplacement['with'].split('.');
if (fileReplacementParts.length > 1 && ['web'].indexOf(fileReplacementParts[1]) >= 0) {
config.target = 'web';
}
break;
}
}
config.plugins = [
...config.plugins ?? [],
new ProvidePlugin({
process: 'process/browser',
})
];
config.resolve!!.fallback = {
path: require.resolve("path-browserify"),
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
vm: require.resolve("vm-browserify"),
};
if (!config.module) {
config.module = {};
}
if (!config.module.rules) {
config.module.rules = [];
}
config.module.rules.push({test: /\.sh/, type: 'asset/source'});
return config;
};