-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
129 lines (124 loc) · 2.53 KB
/
webpack.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
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
119
120
121
122
123
124
125
126
127
128
129
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const { merge } = require('webpack-merge');
/* eslint-enable @typescript-eslint/no-var-requires */
const commonConf = {
context: path.resolve(__dirname, 'src'),
externals: [
'@getflywheel/local/renderer',
'@getflywheel/local/main',
'@getflywheel/local',
'react',
'@getflywheel/local-components',
'react-dom',
'react-router-dom',
],
devtool: 'source-map',
/**
* @todo make this configurable
*/
mode: 'development',
module: {
rules: [
{
test: /\.[tj]sx?$/,
exclude: [/node_modules/],
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: 'tsconfig.json',
onlyCompileBundledFiles: true,
},
},
],
},
],
},
node: {
global: false,
__dirname: false,
},
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js'],
},
output: {
filename: '[name].js',
path: path.join(__dirname, 'lib'),
libraryTarget: 'commonjs2',
},
};
const configs = [
{
entry: {
renderer: './renderer.tsx',
},
module: {
rules: [
{
test: /\.svg$/,
issuer: /\.[tj]sx?$/,
use: [{
loader: '@svgr/webpack',
options: {
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
inlineStyles: false,
},
},
},
],
},
},
}],
},
{
test: /\.(css|scss)$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: {
localIdentName: `[local]_[hash:base64:5]`,
},
},
},
'resolve-url-loader',
'sass-loader',
],
},
],
},
target: 'electron-renderer',
},
{
// entry: glob.sync('./src/main/**/!(test).ts').reduce((entry, file) => {
// // const name = path.basename(file, 'ts');
// let name = file.replace(/^\.\/src\//, '').replace(/\.ts/, '');
// console.log(file, name, path.join(__dirname, file))
// /**
// * @todo figure out how to exclude test files with the glob pattern
// */
// if (!name.includes('.test')) {
// entry[name] = path.join(__dirname, file);
// }
// return entry;
// }, {
// main: './main.ts',
// }),
entry: {
main: './main.ts',
},
target: 'electron-main',
externals: [nodeExternals()],
},
].map((config) => merge(commonConf, config));
module.exports = configs;