-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.renderer.js
61 lines (57 loc) · 1.84 KB
/
webpack.config.renderer.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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const port = parseInt(process.env.PORT, 10) || 8080;
const isDevelopment = process.env.NODE_ENV === 'development';
const baseEntry = ['babel-polyfill', './src/renderer/index.jsx'];
const developmentEntry = [
'react-hot-loader/patch',
`webpack-dev-server/client?http://localhost:${port}`,
'webpack/hot/only-dev-server',
];
const productionEntry = [];
const basePlugins = [
new webpack.EnvironmentPlugin(['NODE_ENV']),
new HtmlWebpackPlugin({ template: 'src/renderer/index.html' }),
];
const developmentPlugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(),
];
const productionPlugins = [
new webpack.LoaderOptionsPlugin({ minimize: true, debug: false }),
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
];
module.exports = {
entry: [...(isDevelopment ? developmentEntry : productionEntry), ...baseEntry],
output: {
path: path.join(__dirname, 'dist'),
filename: 'renderer.js',
},
module: {
rules: [
{ test: /\.jsx?$/, loader: 'eslint-loader', enforce: 'pre' },
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
babelrc: false,
presets: [['latest', { es2015: { modules: false } }], 'stage-0', 'react'],
plugins: ['react-hot-loader/babel'],
},
},
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
],
},
resolve: { extensions: ['.js', '.jsx', 'json'] },
plugins: [...basePlugins, ...(isDevelopment ? developmentPlugins : productionPlugins)],
devServer: {
port,
compress: true,
hot: true,
historyApiFallback: true,
},
devtool: isDevelopment ? 'eval-source-map' : false,
target: 'electron-renderer',
};