-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.electron-renderer.config.js
73 lines (67 loc) · 1.88 KB
/
webpack.electron-renderer.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
const path = require('path');
const tracker = require('./webpack-asset-tracker');
module.exports = function(env, argv) {
const mode = (argv && argv.mode) || 'production';
const devMode = mode === 'development';
const devtool = devMode ? 'inline-source-map' : undefined;
const output = {
filename: 'dazzler_[name]_[contenthash].js',
sourceMapFilename: 'dazzler_[name]_[contenthash][ext].map',
library: 'dazzler_[name]',
libraryTarget: 'umd',
devtoolModuleFilenameTemplate: 'webpack:///[id]/[resource]?[loaders]',
globalObject: 'self'
};
const entry = {
electron: [path.join(__dirname, 'src/electron/renderer/index.ts')]
};
if (devMode) {
output.path = path.join(__dirname, 'dazzler/assets/electron/dev');
} else {
output.path = path.join(__dirname, 'dazzler/assets/electron/dist');
}
const plugins = [
tracker({
path: output.path,
filename: 'assets.json',
integrity: false,
}),
];
const externals = {
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
umd: 'react',
root: 'React',
},
'react-dom': {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'react-dom',
umd: 'react-dom',
root: 'ReactDOM',
},
};
return {
mode,
devtool,
target: 'electron-renderer',
entry,
output,
plugins,
externals,
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
};
};