WordPress.org

Make WordPress Core

Changeset 43978 for trunk


Ignore:
Timestamp:
12/11/2018 04:38:21 PM (3 years ago)
Author:
atimmer
Message:

Build tools: Combine webpack config files.

This prepares us for building the Gutenberg packages.

Merges [43687] to trunk.
See #45065.

Location:
trunk
Files:
2 deleted
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Gruntfile.js

    r43571 r43978  
    11/* jshint node:true */
    22/* globals Set */
    3 var webpackConfig = require( './webpack.config.prod' );
    4 var webpackDevConfig = require( './webpack.config.dev' );
     3var webpackConfig = require( './webpack.config' );
    54
    65module.exports = function(grunt) {
     
    705704        },
    706705        webpack: {
    707             prod: webpackConfig,
    708             dev: webpackDevConfig
     706            prod: webpackConfig( { environment: 'production' } ),
     707            dev: webpackConfig( { environment: 'development' } )
    709708        },
    710709        concat: {
     
    10911090                files: [
    10921091                    'Gruntfile.js',
    1093                     'webpack-dev.config.js',
    10941092                    'webpack.config.js'
    10951093                ]
  • trunk/webpack.config.js

    r43687 r43978  
    1 var path         = require( 'path' ),
    2     SOURCE_DIR   = 'src/',
    3     mediaEntries  = {},
    4     mediaBuilds  = [ 'audiovideo', 'grid', 'models', 'views' ],
    5     webpack      = require( 'webpack' );
     1var path            = require( 'path' ),
     2    webpack         = require( 'webpack' ),
     3    admin_files     = {},
     4    include_files   = {};
    65
    7 mediaBuilds.forEach( function ( build ) {
    8     var path = SOURCE_DIR + 'wp-includes/js/media';
    9     mediaEntries[ build ] = './' + path + '/' + build + '.manifest.js';
    10 } );
     6include_files = {
     7    'build/wp-includes/js/media-audiovideo.js': ['./src/js/_enqueues/wp/media/audiovideo.js'],
     8    'build/wp-includes/js/media-audiovideo.min.js': ['./src/js/_enqueues/wp/media/audiovideo.js'],
     9    'build/wp-includes/js/media-grid.js': ['./src/js/_enqueues/wp/media/grid.js'],
     10    'build/wp-includes/js/media-grid.min.js': ['./src/js/_enqueues/wp/media/grid.js'],
     11    'build/wp-includes/js/media-models.js': ['./src/js/_enqueues/wp/media/models.js'],
     12    'build/wp-includes/js/media-models.min.js': ['./src/js/_enqueues/wp/media/models.js'],
     13    'build/wp-includes/js/media-views.js': ['./src/js/_enqueues/wp/media/views.js'],
     14    'build/wp-includes/js/media-views.min.js': ['./src/js/_enqueues/wp/media/views.js'],
     15};
    1116
    1217module.exports = function( env = { environment: "production" } ) {
     
    1520    const mediaConfig = {
    1621        cache: true,
    17         entry: mediaEntries,
     22        entry: Object.assign( admin_files, include_files ),
    1823        output: {
    19             path: path.join( __dirname, 'src/wp-includes/js' ),
    20             filename: 'media-[name].js'
    21         }
     24            filename: '[name]',
     25        },
     26        plugins: [
     27            new webpack.optimize.UglifyJsPlugin({
     28                include: /\.min\.js$/,
     29                minimize: true
     30            })
     31        ]
    2232    };
    2333
    24     if ( mode === 'development' ) {
    25         mediaConfig.watch = true;
    26     }
    27 
    2834    if ( mode === 'production' ) {
    29         mediaConfig.plugins = [
    30             new webpack.optimize.ModuleConcatenationPlugin()
    31         ];
     35        mediaConfig.plugins.push( new webpack.optimize.ModuleConcatenationPlugin() );
    3236    }
    3337
Note: See TracChangeset for help on using the changeset viewer.