-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.ts
118 lines (114 loc) · 2.5 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* Webpack configuration for Electron's
* main and renderer processes.
*
* @module
*/
import 'dotenv/config';
import path from 'path';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import CopyPlugin from 'copy-webpack-plugin';
import { EnvironmentPlugin } from 'webpack';
import type { Configuration, ModuleOptions } from 'webpack';
/**
* Webpack shared configuration.
*
* @constant
*/
const WebpackSharedConfig: Partial<Configuration> = {
resolve: {
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
alias: {
'@liga': path.resolve(__dirname, 'src'),
'package.json': path.resolve(__dirname, 'package.json'),
},
},
};
/**
* Webpack module rules.
*
* @constant
*/
const WebpackRulesConfig: Required<ModuleOptions>['rules'] = [
{
test: /native_modules\/.+\.node$/,
use: 'node-loader',
},
{
test: /\.(m?js|node)$/,
exclude: /\.prisma/,
parser: { amd: false },
use: {
loader: '@vercel/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
},
},
},
{
test: /\.tsx?$/,
exclude: /(node_modules|\.webpack)/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
},
];
/**
* Webpack configuration options for
* the main Electron process.
*
* @constant
*/
export const ElectronMainWebpackConfig: Configuration = {
...WebpackSharedConfig,
entry: './src/backend/index.ts',
module: { rules: WebpackRulesConfig },
plugins: [
new EnvironmentPlugin([
'GH_ISSUES_CLIENT_ID',
'FIREBASE_CLIENT_EMAIL',
'FIREBASE_KEY_ID',
'FIREBASE_PROJECT_ID',
]),
new CopyPlugin({
patterns: [{ from: './node_modules/.prisma/client' }],
}),
],
};
/**
* Webpack configuration options for
* the renderer Electron process.
*
* @constant
*/
export const ElectronRendererWebpackConfig: Configuration = {
...WebpackSharedConfig,
module: {
rules: [
...WebpackRulesConfig,
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: ['tailwindcss/nesting', 'tailwindcss', 'autoprefixer'],
},
},
},
],
},
{
test: /(\.mp4|\.png|\.webm)$/,
type: 'asset/inline',
},
],
},
plugins: [new ForkTsCheckerWebpackPlugin()],
};