mirror of
https://github.com/Fabio286/antares.git
synced 2025-04-15 10:37:28 +02:00
build: webpack workers configuration
This commit is contained in:
parent
4276586e11
commit
4051eff382
@ -8,13 +8,14 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"debug": "npm run rebuild:electron && npm run debug-runner",
|
"debug": "npm run rebuild:electron && npm run debug-runner",
|
||||||
"debug-runner": "node scripts/devRunner.js --remote-debug",
|
"debug-runner": "node scripts/devRunner.js --remote-debug",
|
||||||
"compile": "npm run compile:main && npm run compile:renderer",
|
"compile": "npm run compile:main && npm run compile:workers && npm run compile:renderer",
|
||||||
"compile:main": "webpack --mode=production --config webpack.main.config.js",
|
"compile:main": "webpack --mode=production --config webpack.main.config.js",
|
||||||
|
"compile:workers": "webpack --mode=production --config webpack.workers.config.js",
|
||||||
"compile:renderer": "webpack --mode=production --config webpack.renderer.config.js",
|
"compile:renderer": "webpack --mode=production --config webpack.renderer.config.js",
|
||||||
"build": "cross-env NODE_ENV=production npm run compile",
|
"build": "cross-env NODE_ENV=production npm run compile",
|
||||||
"build:local": "npm run build && electron-builder",
|
"build:local": "npm run build && electron-builder",
|
||||||
"build:appx": "npm run build:local -- --win appx",
|
"build:appx": "npm run build:local -- --win appx",
|
||||||
"rebuild:electron": "npm run postinstall",
|
"rebuild:electron": "rimraf ./dist && npm run postinstall",
|
||||||
"release": "standard-version",
|
"release": "standard-version",
|
||||||
"release:pre": "npm run release -- --prerelease alpha",
|
"release:pre": "npm run release -- --prerelease alpha",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
@ -136,7 +137,6 @@
|
|||||||
"all-contributors-cli": "^6.20.0",
|
"all-contributors-cli": "^6.20.0",
|
||||||
"babel-loader": "^8.2.3",
|
"babel-loader": "^8.2.3",
|
||||||
"chalk": "^4.1.2",
|
"chalk": "^4.1.2",
|
||||||
"clean-webpack-plugin": "^4.0.0",
|
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"css-loader": "^6.5.0",
|
"css-loader": "^6.5.0",
|
||||||
"electron": "^17.0.1",
|
"electron": "^17.0.1",
|
||||||
@ -154,6 +154,7 @@
|
|||||||
"node-loader": "^2.0.0",
|
"node-loader": "^2.0.0",
|
||||||
"playwright": "^1.18.1",
|
"playwright": "^1.18.1",
|
||||||
"progress-webpack-plugin": "^1.0.12",
|
"progress-webpack-plugin": "^1.0.12",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
"sass": "^1.42.1",
|
"sass": "^1.42.1",
|
||||||
"sass-loader": "^12.3.0",
|
"sass-loader": "^12.3.0",
|
||||||
"standard-version": "^9.3.1",
|
"standard-version": "^9.3.1",
|
||||||
|
@ -12,7 +12,7 @@ const { spawn } = require('child_process');
|
|||||||
|
|
||||||
const mainConfig = require('../webpack.main.config');
|
const mainConfig = require('../webpack.main.config');
|
||||||
const rendererConfig = require('../webpack.renderer.config');
|
const rendererConfig = require('../webpack.renderer.config');
|
||||||
// const workersConfig = require('../webpack.workers.config');
|
const workersConfig = require('../webpack.workers.config');
|
||||||
|
|
||||||
let electronProcess = null;
|
let electronProcess = null;
|
||||||
let manualRestart = null;
|
let manualRestart = null;
|
||||||
@ -64,7 +64,7 @@ async function restartElectron () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startMain () {
|
function startMain () {
|
||||||
const webpackSetup = webpack(mainConfig);
|
const webpackSetup = webpack([mainConfig, workersConfig]);
|
||||||
|
|
||||||
webpackSetup.compilers.forEach((compiler) => {
|
webpackSetup.compilers.forEach((compiler) => {
|
||||||
const { name } = compiler;
|
const { name } = compiler;
|
||||||
|
75
src/main/workers/exporterProcess.js
Normal file
75
src/main/workers/exporterProcess.js
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// import MysqlExporter from '../libs/exporters/sql/MysqlExporter.js';
|
||||||
|
// import path from 'path';
|
||||||
|
// import fs from 'fs';
|
||||||
|
// let exporter;
|
||||||
|
|
||||||
|
// switch (type) {
|
||||||
|
// case 'mysql':
|
||||||
|
// case 'maria':
|
||||||
|
// exporter = new MysqlExporter(connections[uid], tables, rest);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// // return {
|
||||||
|
// // status: 'error',
|
||||||
|
// // response: `${type} exporter not aviable`
|
||||||
|
// // };
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const outputFileName = path.basename(rest.outputFile);
|
||||||
|
|
||||||
|
// if (fs.existsSync(rest.outputFile)) {
|
||||||
|
// const result = await dialog.showMessageBox({
|
||||||
|
// type: 'warning',
|
||||||
|
// message: `File ${outputFileName} already exists. Do you want to replace it?`,
|
||||||
|
// detail:
|
||||||
|
// 'A file with the same name already exists in the target folder. Replacing it will overwrite its current contents.',
|
||||||
|
// buttons: ['Cancel', 'Replace'],
|
||||||
|
// defaultId: 0,
|
||||||
|
// cancelId: 0
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if (result.response !== 1)
|
||||||
|
// exporter = null;
|
||||||
|
// // return { status: 'error', response: 'Operation aborted' };
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // return new Promise((resolve, reject) => {
|
||||||
|
// exporter.once('error', err => {
|
||||||
|
// reject(err);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// exporter.once('end', () => {
|
||||||
|
// resolve({ cancelled: exporter.isCancelled });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// exporter.once('cancel', () => {
|
||||||
|
// fs.unlinkSync(exporter.outputFile);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// exporter.on('progress', state => {
|
||||||
|
// event.sender.send('export-progress', state);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// exporter.run();
|
||||||
|
// // })
|
||||||
|
// // .then(response => {
|
||||||
|
// // if (!response.cancelled) {
|
||||||
|
// // new Notification({
|
||||||
|
// // title: 'Export finished',
|
||||||
|
// // body: `Finished exporting to ${outputFileName}`
|
||||||
|
// // }).show();
|
||||||
|
// // }
|
||||||
|
// // return { status: 'success', response };
|
||||||
|
// // })
|
||||||
|
// // .catch(err => {
|
||||||
|
// // new Notification({
|
||||||
|
// // title: 'Export error',
|
||||||
|
// // body: err.toString()
|
||||||
|
// // }).show();
|
||||||
|
|
||||||
|
// // return { status: 'error', response: err.toString() };
|
||||||
|
// // })
|
||||||
|
// // .finally(() => {
|
||||||
|
// // exporter.removeAllListeners();
|
||||||
|
// // exporter = null;
|
||||||
|
// // });
|
@ -1,70 +1,72 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
const webpack = require('webpack');
|
||||||
const ProgressPlugin = require('progress-webpack-plugin');
|
const ProgressPlugin = require('progress-webpack-plugin');
|
||||||
|
|
||||||
const { dependencies, devDependencies } = require('./package.json');
|
const { dependencies, devDependencies, version } = require('./package.json');
|
||||||
|
|
||||||
const externals = Object.keys(dependencies).concat(Object.keys(devDependencies));
|
const externals = Object.keys(dependencies).concat(Object.keys(devDependencies));
|
||||||
const isDevMode = process.env.NODE_ENV === 'development';
|
const isDevMode = process.env.NODE_ENV === 'development';
|
||||||
const whiteListedModules = [];
|
const whiteListedModules = [];
|
||||||
|
|
||||||
module.exports = [
|
module.exports = { // Main
|
||||||
{ // Main
|
name: 'main',
|
||||||
name: 'main',
|
mode: process.env.NODE_ENV,
|
||||||
mode: process.env.NODE_ENV,
|
devtool: isDevMode ? 'eval-source-map' : false,
|
||||||
devtool: isDevMode ? 'eval-source-map' : false,
|
entry: {
|
||||||
entry: {
|
main: path.join(__dirname, './src/main/main.js')
|
||||||
main: path.join(__dirname, './src/main/main.js')
|
},
|
||||||
|
target: 'electron-main',
|
||||||
|
output: {
|
||||||
|
libraryTarget: 'commonjs2',
|
||||||
|
path: path.join(__dirname, 'dist'),
|
||||||
|
filename: '[name].js'
|
||||||
|
},
|
||||||
|
node: {
|
||||||
|
global: true,
|
||||||
|
__dirname: isDevMode,
|
||||||
|
__filename: isDevMode
|
||||||
|
},
|
||||||
|
externals: externals.filter((d) => !whiteListedModules.includes(d)),
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.js', '.json'],
|
||||||
|
alias: {
|
||||||
|
src: path.join(__dirname, 'src/'),
|
||||||
|
common: path.resolve(__dirname, 'src/common')
|
||||||
},
|
},
|
||||||
target: 'electron-main',
|
fallback: {
|
||||||
output: {
|
'pg-native': false,
|
||||||
libraryTarget: 'commonjs2',
|
'cpu-features': false,
|
||||||
path: path.join(__dirname, 'dist'),
|
cardinal: false
|
||||||
filename: '[name].js'
|
|
||||||
},
|
|
||||||
node: {
|
|
||||||
global: true,
|
|
||||||
__dirname: isDevMode,
|
|
||||||
__filename: isDevMode
|
|
||||||
},
|
|
||||||
externals: externals.filter((d) => !whiteListedModules.includes(d)),
|
|
||||||
resolve: {
|
|
||||||
extensions: ['.js', '.json'],
|
|
||||||
alias: {
|
|
||||||
src: path.join(__dirname, 'src/'),
|
|
||||||
common: path.resolve(__dirname, 'src/common')
|
|
||||||
},
|
|
||||||
fallback: {
|
|
||||||
'pg-native': false,
|
|
||||||
'cpu-features': false,
|
|
||||||
cardinal: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new ProgressPlugin(true),
|
|
||||||
new CleanWebpackPlugin({ root: path.join(__dirname, 'dist') })
|
|
||||||
],
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.node$/,
|
|
||||||
loader: 'node-loader',
|
|
||||||
options: {
|
|
||||||
name: '[path][name].[ext]'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader: 'babel-loader'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(png|jpg|gif)$/,
|
|
||||||
use: [{
|
|
||||||
loader: 'file-loader'
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new ProgressPlugin(true),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': {
|
||||||
|
PACKAGE_VERSION: `"${version}"`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
],
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.node$/,
|
||||||
|
loader: 'node-loader',
|
||||||
|
options: {
|
||||||
|
name: '[path][name].[ext]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: 'babel-loader'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(png|jpg|gif)$/,
|
||||||
|
use: [{
|
||||||
|
loader: 'file-loader'
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
];
|
};
|
||||||
|
80
webpack.workers.config.js
Normal file
80
webpack.workers.config.js
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const ProgressPlugin = require('progress-webpack-plugin');
|
||||||
|
|
||||||
|
const { dependencies, devDependencies, version } = require('./package.json');
|
||||||
|
|
||||||
|
const externals = Object.keys(dependencies).concat(Object.keys(devDependencies));
|
||||||
|
const isDevMode = process.env.NODE_ENV === 'development';
|
||||||
|
const whiteListedModules = [];
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
name: 'workers',
|
||||||
|
mode: process.env.NODE_ENV,
|
||||||
|
devtool: isDevMode ? 'eval-source-map' : false,
|
||||||
|
entry: {
|
||||||
|
exporterProcess: path.join(__dirname, './src/main/workers/exporterProcess.js')
|
||||||
|
},
|
||||||
|
target: 'node',
|
||||||
|
output: {
|
||||||
|
libraryTarget: 'commonjs2',
|
||||||
|
path: path.join(__dirname, 'dist'),
|
||||||
|
filename: '[name].js'
|
||||||
|
},
|
||||||
|
node: {
|
||||||
|
global: true,
|
||||||
|
__dirname: isDevMode,
|
||||||
|
__filename: isDevMode
|
||||||
|
},
|
||||||
|
externals: externals.filter((d) => !whiteListedModules.includes(d)),
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
use: 'babel-loader',
|
||||||
|
exclude: /node_modules/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.node$/,
|
||||||
|
use: 'node-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.js', '.json'],
|
||||||
|
alias: {
|
||||||
|
src: path.join(__dirname, 'src/'),
|
||||||
|
common: path.resolve(__dirname, 'src/common')
|
||||||
|
},
|
||||||
|
fallback: {
|
||||||
|
'pg-native': false,
|
||||||
|
'cpu-features': false,
|
||||||
|
cardinal: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new ProgressPlugin(true),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': {
|
||||||
|
PACKAGE_VERSION: `"${version}"`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjust rendererConfig for production settings
|
||||||
|
*/
|
||||||
|
if (isDevMode) {
|
||||||
|
// any dev only config
|
||||||
|
config.plugins.push(new webpack.HotModuleReplacementPlugin());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
config.plugins.push(
|
||||||
|
new webpack.LoaderOptionsPlugin({
|
||||||
|
minimize: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = config;
|
Loading…
x
Reference in New Issue
Block a user