forked from getflywheel/local-addon-instant-reload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
113 lines (109 loc) · 2.06 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
/* 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',
module: {
rules: [
{
test: /\.[tj]sx?$/,
exclude: [/node_modules/],
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: 'tsconfig.json',
onlyCompileBundledFiles: true,
},
},
],
},
],
},
node: {
fs: 'empty',
/* eslint-disable-next-line camelcase */
child_process: 'empty',
__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: {
test: /\.[tj]sx?$/,
},
use: [
'babel-loader',
{
loader: 'react-svg-loader',
options: {
svgo: {
plugins: [
{
inlineStyles: { onlyMatchedOnce: false },
},
],
},
},
},
],
},
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
sourceMap: true,
importLoaders: 1,
},
},
// 'css-loader',
'resolve-url-loader',
'sass-loader',
],
},
],
},
target: 'electron-renderer',
},
{
entry: {
main: './main.ts',
instantReloadProcess: './main/instantReloadProcess.ts',
},
target: 'electron-main',
externals: [nodeExternals()],
},
].map((config) => merge(commonConf, config));
module.exports = configs;