Add HMR support
This commit is contained in:
parent
de3639f29c
commit
0b82953d8a
6 changed files with 96 additions and 16 deletions
|
@ -6,10 +6,64 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|||
const STATIC_ROOT = path.resolve(__dirname, 'static/');
|
||||
const DIST_ROOT = path.resolve(__dirname, 'dist/');
|
||||
|
||||
const electronConfig = {
|
||||
target: 'electron-renderer',
|
||||
|
||||
const mainConfig = {
|
||||
target: 'electron-main',
|
||||
entry: {
|
||||
main: './src/platforms/electron/index.js',
|
||||
},
|
||||
output: {
|
||||
filename: '[name]/bundle.js',
|
||||
path: __dirname + '/dist/electron',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.node$/,
|
||||
use: 'node-loader',
|
||||
},
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'preprocess-loader',
|
||||
options: {
|
||||
TARGET: 'app',
|
||||
ppOptions: {
|
||||
type: 'js',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
// 'src/electron': path.resolve(__dirname, 'src/platforms/electron');
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin([
|
||||
{
|
||||
from: `${STATIC_ROOT}/`,
|
||||
to: `${DIST_ROOT}/electron/static/`,
|
||||
ignore: ['font/**/*', 'index.html'],
|
||||
},
|
||||
{
|
||||
from: `${STATIC_ROOT}/index.html`,
|
||||
to: `${DIST_ROOT}/electron/index.html`,
|
||||
},
|
||||
]),
|
||||
],
|
||||
devServer: {
|
||||
contentBase: path.join(__dirname, 'dist/electron')
|
||||
},
|
||||
};
|
||||
|
||||
const renderConfig = {
|
||||
target: 'electron-renderer',
|
||||
entry: {
|
||||
ui: './src/ui/index.js',
|
||||
},
|
||||
output: {
|
||||
|
@ -58,4 +112,7 @@ const electronConfig = {
|
|||
],
|
||||
};
|
||||
|
||||
module.exports = merge(baseConfig, electronConfig);
|
||||
module.exports = [
|
||||
merge(baseConfig, mainConfig),
|
||||
merge(baseConfig, renderConfig),
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue