-
-
Notifications
You must be signed in to change notification settings - Fork 787
/
webpack.config.js
118 lines (111 loc) · 2.94 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
'use strict';
const {resolve} = require('path')
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const {CheckerPlugin} = require('awesome-typescript-loader')
const webpack = require('webpack')
const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development'
const watch = process.env.WEBPACK_WATCH === 'true'
const distPath = resolve(__dirname, 'dist')
const base = {
mode, watch,
output: {
path: distPath,
chunkFilename: '[name].chunk.js',
filename: '[name].js'
},
node: {
Buffer: false,
buffer: false,
__dirname: false,
__filename: false,
},
module: {
rules: [{
test: /\.(ts|tsx)$/,
use: [{
loader: 'awesome-typescript-loader',
options: {
reportFiles: ['src/**/*.{ts,tsx}'],
useCache: true,
useBabel: true,
babelCore: '@babel/core'
}
}],
exclude: /node_modules/
}, {
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
}, {
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
}, {
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}, {
test: /\.(png|jpg)$/,
use: [{
loader: "file-loader"
}]
}, {
test: /\.(eot|woff|ttf)$/,
use: [{
loader: "file-loader"
}]
}]
},
externals: {
'system': '{}', // jsonlint
'file': '{}' // jsonlint
},
}
const renderPlugins = [
new HtmlWebpackPlugin({title: 'Medis', chunks: ['main'], filename: 'main.html'}),
new HtmlWebpackPlugin({title: 'Manage Patterns', chunks: ['patternManager'], filename: 'patternManager.html'}),
new MiniCssExtractPlugin({filename: '[name].css'}),
new CheckerPlugin(),
new webpack.ProvidePlugin({React: 'react'}),
]
if (mode === 'production') {
renderPlugins.push(new BundleAnalyzerPlugin())
}
const renderer = Object.assign({}, base, {
target: 'electron-renderer',
output: Object.assign({}, base.output, {
path: resolve(base.output.path, 'renderer')
}),
entry: {
main: resolve(__dirname, 'src/renderer/windows/MainWindow/entry.jsx'),
patternManager: resolve(__dirname, 'src/renderer/windows/PatternManagerWindow/entry.jsx')
},
plugins: renderPlugins,
resolve: {
alias: {
Redux: resolve(__dirname, 'src/renderer/redux/'),
Utils: resolve(__dirname, 'src/renderer/utils/'),
},
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
})
const main = Object.assign({}, base, {
target: 'electron-main',
output: Object.assign({}, base.output, {
path: resolve(base.output.path, 'main')
}),
entry: {
index: resolve(__dirname, 'src/main/index.ts')
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
})
module.exports = [main, renderer]