This repository has been archived by the owner on Jun 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
webpack.config.dev.js
109 lines (107 loc) · 2.65 KB
/
webpack.config.dev.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
const { spawn } = require('child_process')
const path = require('path')
const webpack = require('webpack')
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
const PORT = process.env.PORT || 7000
const PUBLIC_PATH = `https://localhost:${PORT}/dist/`
module.exports = {
bail: true,
// sourcemaps
devtool: 'cheap-module-eval-source-map',
target: 'electron-renderer',
// input
entry: [
`webpack-dev-server/client?https://localhost:${PORT}/`,
'webpack/hot/only-dev-server',
'./app/renderer/index.js'
],
// output
output: {
publicPath: PUBLIC_PATH,
filename: 'renderer.dev.js'
},
// transformations
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'babel-loader',
options: {
// https://github.com/babel/babel-loader#options
cacheDirectory: true,
}
},
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{
test: /\.(gif|png|jpg|jpeg)$/,
loader: 'url-loader?limit=8192&name=[path][name].[ext]?[hash]' // inline base64 URLs for <=8k, direct URLs for the rest
},
{
test: /\.(ico|woff|woff2|ttf|eot)$/,
loader: 'url-loader?limit=1&name=[path][name].[ext]'
},
{
test: /\.svg$/,
loader: 'svg-sprite-loader'
}
]
},
// plugins
plugins: [
new webpack.HotModuleReplacementPlugin({
multiStep: true
}),
new webpack.NoEmitOnErrorsPlugin(),
new MonacoWebpackPlugin({
languages: ['javascript', 'typescript']
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development')
},
'process.browser': true
})
],
// manipulations
resolve: {
alias: {
'@': path.resolve(__dirname, 'app', 'renderer')
}
},
// dev server
devServer: {
https: true,
port: PORT,
publicPath: PUBLIC_PATH,
compress: true,
noInfo: true,
stats: 'errors-only',
inline: true,
lazy: false,
hot: true,
headers: { 'Access-Control-Allow-Origin': '*' },
contentBase: path.join(__dirname, 'dist'),
watchOptions: {
aggregateTimeout: 300,
ignored: /node_modules/,
poll: 100
},
historyApiFallback: {
verbose: true,
disableDotRule: false
},
before() {
if (process.env.START_HOT) {
console.log('Starting Main Process...')
spawn('npm', ['run', 'start-main-dev'], {
shell: true,
env: process.env,
stdio: 'inherit'
})
.on('close', code => process.exit(code))
.on('error', spawnError => console.error(spawnError))
}
}
}
}