build.js 931 Bytes
process.env.NODE_ENV = 'production';

const rm = require('rimraf');
const path = require('path');
const webpack = require('webpack');
const clientConfig = require('./webpack.client.conf');
const serverConfig = require('./webpack.server.conf');

rm(path.join(clientConfig.output.path), err => {
  if (err) {
    throw err;
  }
  webpack(clientConfig, (clientErr, clientStats) => {
    if (clientErr) {
      throw clientErr;
    }
    process.stdout.write(clientStats.toString({
      colors: true,
      modules: false,
      children: false,
      chunks: false,
      chunkModules: false
    }) + '\n\n');

    webpack(serverConfig, (serverErr, serverStats) => {
      if (serverErr) {
        throw serverErr;
      }
      process.stdout.write(serverStats.toString({
        colors: true,
        modules: false,
        children: false,
        chunks: false,
        chunkModules: false
      }) + '\n\n');
    });
  });
});