-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.renderer.dev.js
More file actions
116 lines (101 loc) · 2.88 KB
/
webpack.config.renderer.dev.js
File metadata and controls
116 lines (101 loc) · 2.88 KB
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
import chalk from 'chalk';
import { execSync, spawn } from 'child_process';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import fs from 'fs';
import path from 'path';
import webpack from 'webpack';
import webpackMerge from 'webpack-merge';
import baseConfig from './webpack.config.base';
const dll = path.resolve(process.cwd(), 'app/dll');
const manifest = path.resolve(dll, 'renderer.json');
const port = process.env.PORT || 8080;
const publicPath = `http://localhost:${port}/dist`;
if (!(fs.existsSync(dll) && fs.existsSync(manifest))) {
console.log(chalk.black.bgYellow.bold(
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"'
));
execSync('npm run build-dll');
}
export default webpackMerge(baseConfig, {
devServer: {
port, publicPath,
compress: true,
contentBase: path.join(__dirname, 'dist'),
inline: true,
hot: true,
lazy: false,
noInfo: true,
setup: () => {
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', error => console.error(error))
}
},
watchOptions: {
aggregateTimeout: 300,
ignored: /node_modules/,
poll: 100
}
},
devtool: 'inline-source-map',
entry: [
'react-hot-loader/patch',
`webpack-dev-server/client?http://localhost:${port}/`,
'webpack/hot/only-dev-server',
path.join(__dirname, 'src/index.js')
],
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
plugins: [
'transform-class-properties',
'transform-es2015-classes',
'react-hot-loader/babel'
],
}
}
},
{
test: /\.styl$/,
loader: 'style-loader!css-loader?modules&importLoaders=2&localIndentName=[name]!stylus-loader?outputStyle=expanded&sourceMap&sourceMapContents&paths=static'
}
]
},
output: {
publicPath: `http://localhost:${port}/dist/`
},
plugins: [
new webpack.DllReferencePlugin({
context: process.cwd(),
manifest: require(manifest),
sourceType: 'var',
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
new webpack.LoaderOptionsPlugin({
debug: true
}),
new ExtractTextPlugin({
filename: '[name].css'
})
],
resolve: {
extensions: ['.js', '.scss'],
modules: ['node_modules', path.join(__dirname, 'src'), path.join(__dirname, 'static')]
},
target: 'electron-renderer'
});