forked from zenghongtu/PPet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.renderer.js
40 lines (35 loc) · 1.17 KB
/
webpack.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
const path = require('path');
const fs = require('fs');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = function(config) {
// https://github.com/electron-userland/electron-webpack/issues/165#issuecomment-475615807
config.plugins.forEach(plugin => {
if (plugin.constructor.name === 'MiniCssExtractPlugin') {
plugin.options.filename = '[id].styles.css';
plugin.options.moduleFilename = name => {
return '[id].styles.css';
};
}
// 修复 HtmlWebpackPlugin 插件会注入所有 chunks 问题
if (plugin.constructor.name === 'HtmlWebpackPlugin') {
plugin.options.chunks = ['renderer'];
}
});
// 创建 第二个窗口 html
config.plugins.push(
new HtmlWebpackPlugin({
template: `!!html-loader?minimize=false&url=false!${path.resolve(
'dist/.renderer-index-template.html'
)}`,
filename: `plugins.html`,
chunks: ['renderer2'],
title: `Plugins`
})
);
config.entry.renderer2 = [
'css-hot-loader/hotModuleReplacement',
path.resolve('src/renderer2/index.tsx')
];
config.resolve.alias.renderer2 = path.resolve('src/renderer2');
return config;
};