summaryrefslogtreecommitdiff
path: root/webpack.production.js
blob: 67387583520c085ab7192b4e21446829e289b02b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var baseConfig = require('./webpackBaseConfig')
var webpack = require('webpack')
var path = require('path')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')

module.exports = [Object.assign({}, baseConfig, {
  plugins: baseConfig.plugins.concat([
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    })
  ]),

  optimization: {
    minimizer: [
      new UglifyJsPlugin({
        parallel: true,
        cache: true
      })
    ],
    splitChunks: {
      chunks: 'async',
      minChunks: Infinity
    }
  },

  output: {
    path: path.join(__dirname, 'public/build'),
    publicPath: '/build/',
    filename: '[id].[name].[hash].js'
    // baseUrl: '<%- url %>'
  }
}), {
  // This Chunk is used in the 'save as html' feature.
  // It is embedded in the html file and contains CSS for styling.

  entry: {
    htmlExport: path.join(__dirname, 'public/js/htmlExport.js')
  },

  output: {
    path: path.join(__dirname, 'public/build'),
    publicPath: '/build/',
    filename: '[name].js'
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new MiniCssExtractPlugin({
      filename: 'html.min.css'
    })
  ],

  optimization: {
    minimizer: [
      new OptimizeCSSAssetsPlugin({})
    ]
  },

  module: {
    rules: [{
      test: /\.css$/,
      use: [
        MiniCssExtractPlugin.loader,
        'css-loader'
      ]
    }]
  }
}]