-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.ts
73 lines (65 loc) · 1.67 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/// <reference path="globals.d.ts" />
import {Configuration, DefinePlugin} from 'webpack'
import {join} from 'path'
import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const packageJson = require('./package.json')
interface WebpackEnv {
testInt?: 'true'
devUI?: 'true'
}
function configs(
env: WebpackEnv,
argv: {
mode: 'development' | 'production'
env: WebpackEnv
},
): Configuration {
const devMode = argv.mode === 'development'
const testIntMode = env.testInt === 'true'
const devUI = env.devUI === 'true'
const outputDir = join(__dirname, 'resources', 'dist')
return {
entry: {
main: join(__dirname, 'src/main-process/main.ts'),
},
target: 'electron-main',
output: {
path: outputDir,
filename: '[name].js',
},
devtool: devMode ? 'eval-source-map' : undefined,
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
plugins: [
new DefinePlugin({
__DEV__: devMode,
__TEST_TEMP_DIR__: JSON.stringify(join(__dirname, '.test-temp')),
__APP_VERSION__: JSON.stringify(packageJson.version),
__APP_NAME__: JSON.stringify(packageJson.name),
__DEV_UI__: devUI,
__JEST__: false,
__INT_TEST__: testIntMode,
__MAIN__: true,
}),
new ForkTsCheckerWebpackPlugin(),
],
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'esbuild-loader',
options: {
target: 'es2020',
tsconfigRaw: require('./tsconfig.json'),
},
},
],
},
],
},
}
}
module.exports = configs