-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.prod.js
51 lines (51 loc) · 1.62 KB
/
webpack.prod.js
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
const merge = require( 'webpack-merge' );
const WebpackAssetsManifest = require( 'webpack-assets-manifest' );
const path = require( 'path' );
const common = require( './webpack.common.js' );
const webpack = require( 'webpack' );
const CleanWebpackPlugin = require( 'clean-webpack-plugin' );
const miniExtract = require( 'mini-css-extract-plugin' );
const wpi18nExtractor = require( './bin/i18n-map-extractor.js' );
const assetsData = Object.create( null );
common.forEach( ( config, index ) => {
common[ index ] = merge( config, {
plugins: [
new CleanWebpackPlugin( [ 'assets/dist', 'translation-map.json' ] ),
new webpack.DefinePlugin( {
'process.env': {
NODE_ENV: JSON.stringify( 'production' ),
},
} ),
new wpi18nExtractor( {
aliases: {
'wp-plugins-page': 'ee-wp-plugins-page',
'data-stores': 'eventespresso-data-stores',
components: 'eventespresso-components',
helpers: 'eventespresso-helpers',
valueObjects: 'eventespresso-value-objects',
hocs: 'eventespresso-hocs',
model: 'eventespresso-model',
validators: 'eventespresso-validators',
'editor-hocs': 'eventespresso-editor-hocs',
},
excludes: [ 'eejs', 'vendor' ],
} ),
new WebpackAssetsManifest( {
output: path.resolve( __dirname,
'assets/dist/build-manifest.json',
),
assets: assetsData,
} ),
new webpack.ProvidePlugin( {
React: 'react',
} ),
new miniExtract( {
filename: 'ee-[name].[contenthash].dist.css',
} ),
],
mode: 'production',
} );
//delete temporary named config item so no config errors
delete common[ index ].configName;
} );
module.exports = common;