Wordpress/webpack.config.js
Anton Timmermans f173141c5b Build tools: Combine webpack config files.
This prepares us for building the Gutenberg packages.

Merges [43687] to trunk.
See #45065.


git-svn-id: https://develop.svn.wordpress.org/trunk@43978 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-11 16:38:21 +00:00

40 lines
1.3 KiB
JavaScript

var path = require( 'path' ),
webpack = require( 'webpack' ),
admin_files = {},
include_files = {};
include_files = {
'build/wp-includes/js/media-audiovideo.js': ['./src/js/_enqueues/wp/media/audiovideo.js'],
'build/wp-includes/js/media-audiovideo.min.js': ['./src/js/_enqueues/wp/media/audiovideo.js'],
'build/wp-includes/js/media-grid.js': ['./src/js/_enqueues/wp/media/grid.js'],
'build/wp-includes/js/media-grid.min.js': ['./src/js/_enqueues/wp/media/grid.js'],
'build/wp-includes/js/media-models.js': ['./src/js/_enqueues/wp/media/models.js'],
'build/wp-includes/js/media-models.min.js': ['./src/js/_enqueues/wp/media/models.js'],
'build/wp-includes/js/media-views.js': ['./src/js/_enqueues/wp/media/views.js'],
'build/wp-includes/js/media-views.min.js': ['./src/js/_enqueues/wp/media/views.js'],
};
module.exports = function( env = { environment: "production" } ) {
const mode = env.environment;
const mediaConfig = {
cache: true,
entry: Object.assign( admin_files, include_files ),
output: {
filename: '[name]',
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
minimize: true
})
]
};
if ( mode === 'production' ) {
mediaConfig.plugins.push( new webpack.optimize.ModuleConcatenationPlugin() );
}
return mediaConfig;
};