forked from HyunmoAhn/Tiny-Timer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
76 lines (75 loc) · 1.88 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
const webpack = require('webpack');
const path = require('path');
const { spawn } = require('child_process');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
timer: './app/page/timer.js',
main: './app/index.js',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
publicPath: process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:3001/' : './',
},
target: 'electron-renderer',
devServer: {
compress: true,
inline: true,
lazy: false,
contentBase: path.join(__dirname, 'build'),
publicPath: 'http://localhost:3001/build',
disableHostCheck: true, // do not use production
historyApiFallback: true,
hot: true,
port: 3001,
before() {
console.log('Start Main Process...');
spawn(
'npm run',
['main'],
{ shell: true, env: process.env, stdio: 'inherit' },
)
.on('close', code => process.exit(code))
.on('error', spawnError => console.error(spawnError));
},
},
module: {
rules: [
{
test: /\.js$/,
include: [path.join(__dirname, '/app/page')],
exclude: /node_modules/,
use: [{ loader: 'babel-loader' }]
},
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader',
]
}
]
},
mode: process.env.NODE_ENV,
plugins: [
new HtmlWebpackPlugin({
chunks: ['timer'],
filename: 'timer.html',
template: path.join(__dirname, './app/page/timer.html'),
inject: 'body',
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
'__DEV__': process.env.NODE_ENV === 'development',
'__PROD__': process.env.NODE_ENV === 'production',
}),
],
node: {
__dirname: false,
__filename: false,
}
}