2018-08-14 12:26:23 +00:00
|
|
|
var fse = require('fs-extra');
|
|
|
|
const util = require('util');
|
|
|
|
|
2018-08-15 11:14:23 +00:00
|
|
|
const webpack = require('webpack');
|
|
|
|
|
|
|
|
const { getReplacements } = require('./app-info');
|
2018-09-27 07:57:49 +00:00
|
|
|
const { hasProcessFlag, root } = require('./helpers.js');
|
2018-08-15 11:14:23 +00:00
|
|
|
|
|
|
|
const replacements = getReplacements();
|
|
|
|
|
2018-09-27 07:57:49 +00:00
|
|
|
const EVENT = process.env.npm_lifecycle_event || '';
|
|
|
|
const PROD = EVENT.includes('prod');
|
|
|
|
|
2018-08-15 11:14:23 +00:00
|
|
|
module.exports = function (config) {
|
2018-08-14 12:26:23 +00:00
|
|
|
config.target = 'electron-renderer';
|
2018-09-27 09:44:56 +00:00
|
|
|
config.output = {
|
|
|
|
path: PROD ? root('build', 'dist') : root('build', 'dev'),
|
|
|
|
filename: '[name].js',
|
|
|
|
crossOriginLoading: false,
|
|
|
|
};
|
2018-10-02 08:54:45 +00:00
|
|
|
// config.resolve.modules = [
|
|
|
|
// root(),
|
|
|
|
// root('build', 'dist', 'node_modules'),
|
|
|
|
// 'node_modules',
|
|
|
|
// ];
|
2018-08-15 11:14:23 +00:00
|
|
|
|
|
|
|
config.plugins.push(
|
|
|
|
new webpack.DefinePlugin(
|
|
|
|
Object.assign({}, replacements, {
|
|
|
|
__PROCESS_KIND__: JSON.stringify('renderer'),
|
|
|
|
})
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
var json = util.inspect(config, { showHidden: false, depth: null });
|
|
|
|
fse.writeFileSync('webpack.js', json, 'utf8');
|
2018-08-14 12:26:23 +00:00
|
|
|
|
|
|
|
return config;
|
|
|
|
};
|