Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

javascript - Issue in webpack configuration with parallel-webpack

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:

enter image description here

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:

enter image description here

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...