Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Multi compiler #16

Closed
DylanPiercey opened this issue Feb 9, 2017 · 2 comments
Closed

Multi compiler #16

DylanPiercey opened this issue Feb 9, 2017 · 2 comments

Comments

@DylanPiercey
Copy link

Is it possible to have a multi compiler configuration with this module?

@geowarin
Copy link
Owner

geowarin commented Feb 9, 2017

Yes, see #9

@geowarin geowarin closed this as completed Feb 9, 2017
@coreyleelarson
Copy link
Contributor

How is this supposed to work?

I included this plugin for each of my configs, which are exported as an array to the webpack multicompiler. When webpack runs, I see logs for each config, sometimes a mix of success and error depending on the compiler results.

This can be extremely confusing if clearConsole: true since there's a possibility that I could see nothing but a [DONE] Compiled successfully in XXXms message for one config when there could be an error in another.

webpack.config.babel.js

import clientConfig from './webpack.config.client.babel';
import serverConfig from './webpack.config.server.babel';

export default [clientConfig, serverConfig];

webpack.config.base.babel.js

import FriendlyErrorsPlugin from 'friendly-errors-webpack-plugin';

export default {
  stats: 'none',
  module: {
    rules: [
      {
        test: /\.js?$/,
        use: 'babel-loader',
        exclude: /node_modules/
      }
    ]
  },
  plugins: [
    new FriendlyErrorsPlugin({
      clearConsole: false
    })
  ]
}

webpack.config.client.babel.js

import path from 'path';
import webpackMerge from 'webpack-merge';
import baseConfig from './webpack.config.base.babel';

export default webpackMerge(baseConfig, {
  target: 'web',
  name: 'client',
  entry: {
    client: './client/client.js'
  },
  output: {
    path: path.resolve('./build/assets'),
    filename: 'scripts/[name].bundle.js'
  }
});

webpack.config.server.babel.js

import path from 'path';
import webpackMerge from 'webpack-merge';
import nodeExternals from 'webpack-node-externals';
import baseConfig from './webpack.config.base.babel';

export default webpackMerge(baseConfig, {
  target: 'node',
  name: 'server',
  externals: [nodeExternals()],
  entry: {
    server: './server/server.js'
  },
  output: {
    path: path.resolve('./build'),
    filename: '[name].bundle.js'
  }
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants