Skip to content

webpack Multiple Targets #1256

Description

@sanonz

Code

// webpack.config.js
module.exports = [
  {
    entry : {
      app: './src/app'
    },
    output: {
      path: path.resolve(__dirname, 'dist/')
      filename: 'assets/js/app.js',
      chunkFilename: `assets/js/${getAssetName('[hash]', '[name]')}.js`
    },
    devServer: {
      hot: true
    }
  },
  {
    entry : {
      app: './src/app.server'
    },
    output: {
      path: path.resolve(__dirname, 'dist/server')
      filename: 'app.js',
      chunkFilename: '[name].js',
      libraryTarget: 'commonjs2'
    },
    target: 'node'
  }
];

Run

npx webpack-dev-server

Expected Behavior

Actual Behavior

All added.

For Bugs; How can we reproduce the behavior?

Example edit: https://github.com/webpack/webpack-dev-server/blob/master/lib/util/addDevServerEntrypoints.js#L22

    [].concat(webpackOptions).forEach((wpOpt) => {
+     if (wpOpt.target === 'node') return;
      if (typeof wpOpt.entry === 'object' && !Array.isArray(wpOpt.entry)) {
        Object.keys(wpOpt.entry).forEach((key) => {
          wpOpt.entry[key] = devClient.concat(wpOpt.entry[key]);
        });
      } else if (typeof wpOpt.entry === 'function') {
        wpOpt.entry = wpOpt.entry(devClient);
      } else {
        wpOpt.entry = devClient.concat(wpOpt.entry);
      }
    });

For Features; What is the motivation and/or use-case for the feature?

server side rendering

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions