With this webpack.renderer.js :
/* eslint-disable @typescript-eslint/no-var-requires */
const rules = require('./webpack.rules');
const plugins = require('./webpack.plugins');
const aliases = require('./webpack.aliases');
module.exports = {
// https://github.com/electron/electron/issues/9920
//target: 'electron-renderer',
target: 'web',
module: {
rules,
},
plugins: plugins,
resolve: {
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
alias: {
// React Hot Loader Patch
'react-dom': '@hot-loader/react-dom',
// Custom Aliases
...aliases,
},
},
};
The electron app works fine:
Now, since I need multiple configurations, based on the example: https://github.com/trivago/parallel-webpack#variants-example ,
I tried to use parallel-webpack in this way:
/* eslint-disable @typescript-eslint/no-var-requires */
const rules = require('./webpack.rules');
const plugins = require('./webpack.plugins');
const aliases = require('./webpack.aliases');
// https://webpack.js.org/concepts/targets/#multiple-targets
// https://github.com/trivago/parallel-webpack#variants-example
var createVariants = require('parallel-webpack').createVariants;
var baseOptions = {
preferredRules: rules,
preferredPlugins: plugins,
preferredExtensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
preferredAliases: aliases
};
var variants = {
target: ['electron-renderer', 'electron-main', 'web']
};
function createConfig(options) {
return {
target: options.target,
module: {
rules: preferredRules,
},
plugins: preferredPlugins,
resolve: {
extensions: preferredExtensions,
alias: {
// React Hot Loader Patch
'react-dom': '@hot-loader/react-dom',
// Custom Aliases
...preferredAliases,
}
}
}
}
But I get this error:
devDependencies:
"node-loader": "^1.0.1",
"parallel-webpack": "^2.6.0",
"electron": "^11.2.1",
"typescript": "^4.0.2",
"webpack": "4"
- OS: Ubuntu 18.04.4 Desktop
- node: v14.5.0
How to solve the problem?
question from:
https://stackoverflow.com/questions/65952168/issue-in-webpack-configuration-with-parallel-webpack