Make WordPress Core

Ticket #40894: 40894.5.diff

File 40894.5.diff, 5.8 KB (added by adamsilverstein, 7 years ago)
  • .jshintrc

    diff --git .jshintrc .jshintrc
    index 0a082dded5..278eac22c3 100644
     
    2121    "Backbone": false,
    2222    "jQuery": false,
    2323    "JSON": false,
    24     "wp": false
     24    "wp": false,
     25    "export": false,
     26    "module": false,
     27    "require": false
    2528  }
    2629}
  • Gruntfile.js

    diff --git Gruntfile.js Gruntfile.js
    index 21dc36611d..4a975a8ac0 100644
     
    11/* jshint node:true */
     2var webpackConfig = require( './webpack.config' );
     3var webpackDevConfig = require( './webpack-dev.config' );
     4
    25module.exports = function(grunt) {
    36        var path = require('path'),
    47                fs = require( 'fs' ),
    58                SOURCE_DIR = 'src/',
    69                BUILD_DIR = 'build/',
    710                BANNER_TEXT = '/*! This file is auto-generated */',
    8                 autoprefixer = require('autoprefixer'),
    9                 mediaConfig = {},
    10                 mediaBuilds = ['audiovideo', 'grid', 'models', 'views'];
     11                autoprefixer = require( 'autoprefixer' );
    1112
    1213        // Load tasks.
    1314        require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks );
    1415        // Load legacy utils
    1516        grunt.util = require('grunt-legacy-util');
    1617
    17         mediaBuilds.forEach( function ( build ) {
    18                 var path = SOURCE_DIR + 'wp-includes/js/media';
    19                 mediaConfig[ build ] = { files : {} };
    20                 mediaConfig[ build ].files[ path + '-' + build + '.js' ] = [ path + '/' + build + '.manifest.js' ];
    21         } );
    22 
    2318        // Project configuration.
    2419        grunt.initConfig({
    2520                postcss: {
    module.exports = function(grunt) { 
    175170                                }
    176171                        }
    177172                },
    178                 browserify: mediaConfig,
    179173                sass: {
    180174                        colors: {
    181175                                expand: true,
    module.exports = function(grunt) { 
    336330                                ]
    337331                        },
    338332                        media: {
    339                                 options: {
    340                                         browserify: true
    341                                 },
    342333                                src: [
    343334                                        SOURCE_DIR + 'wp-includes/js/media/**/*.js'
    344335                                ]
    module.exports = function(grunt) { 
    559550                                dest: SOURCE_DIR + 'wp-includes/js/jquery/jquery.masonry.min.js'
    560551                        }
    561552                },
    562 
     553                webpack: {
     554                        prod: webpackConfig,
     555                        dev: webpackDevConfig
     556                },
    563557                concat: {
    564558                        tinymce: {
    565559                                options: {
    module.exports = function(grunt) { 
    742736                                }
    743737                        },
    744738                        config: {
    745                                 files: 'Gruntfile.js'
     739                                files: [
     740                                        'Gruntfile.js',
     741                                        'webpack-dev.config.js',
     742                                        'webpack.config.js'
     743                                ]
    746744                        },
    747745                        colors: {
    748746                                files: [SOURCE_DIR + 'wp-admin/css/colors/**'],
    module.exports = function(grunt) { 
    780778
    781779        // Register tasks.
    782780
     781        // Webpack task.
     782        grunt.loadNpmTasks( 'grunt-webpack' );
     783
    783784        // RTL task.
    784785        grunt.registerTask('rtl', ['rtlcss:core', 'rtlcss:colors']);
    785786
    module.exports = function(grunt) { 
    803804        grunt.renameTask( 'watch', '_watch' );
    804805
    805806        grunt.registerTask( 'watch', function() {
    806                 if ( ! this.args.length || this.args.indexOf( 'browserify' ) > -1 ) {
    807                         grunt.config( 'browserify.options', {
    808                                 browserifyOptions: {
    809                                         debug: true
    810                                 },
    811                                 watch: true
    812                         } );
     807                if ( ! this.args.length || this.args.indexOf( 'webpack' ) > -1 ) {
    813808
    814                         grunt.task.run( 'browserify' );
     809                        grunt.task.run( 'webpack:dev' );
    815810                }
    816811
    817812                grunt.task.run( '_' + this.nameArgs );
    module.exports = function(grunt) { 
    822817        ] );
    823818
    824819        grunt.registerTask( 'precommit:js', [
    825                 'browserify',
     820                'webpack:prod',
    826821                'jshint:corejs',
    827822                'uglify:bookmarklet',
    828823                'uglify:masonry',
    module.exports = function(grunt) { 
    891886                                        return regex.test( result.stdout );
    892887                                }
    893888
    894                                 if ( [ 'package.json', 'Gruntfile.js' ].some( testPath ) ) {
     889                                if ( [ 'package.json', 'Gruntfile.js', 'webpack.config.js' ].some( testPath ) ) {
    895890                                        grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' );
    896891                                        taskList.push( 'prerelease' );
    897892                                } else {
    module.exports = function(grunt) { 
    989984        grunt.event.on('watch', function( action, filepath, target ) {
    990985                var src;
    991986
    992                 if ( [ 'all', 'rtl', 'browserify' ].indexOf( target ) === -1 ) {
     987                if ( [ 'all', 'rtl', 'webpack' ].indexOf( target ) === -1 ) {
    993988                        return;
    994989                }
    995990
  • package.json

    diff --git package.json package.json
    index 71695dfb77..10b36c0727 100644
     
    1515    "autoprefixer": "^6.5.1",
    1616    "grunt": "~0.4.5",
    1717    "grunt-banner": "^0.6.0",
    18     "grunt-browserify": "~5.0.0",
    1918    "grunt-contrib-clean": "~1.0.0",
    2019    "grunt-contrib-compress": "~1.3.0",
    2120    "grunt-contrib-concat": "~1.0.0",
     
    3635    "grunt-rtlcss": "~2.0.1",
    3736    "grunt-sass": "~1.2.1",
    3837    "ink-docstrap": "^1.3.0",
     38    "grunt-webpack": "^3.0.2",
    3939    "matchdep": "~1.0.0"
     40    "webpack": "^3.5.4",
     41    "webpack-dev-server": "^2.7.1"
    4042  }
    4143}
  • new file webpack-dev.config.js

    diff --git webpack-dev.config.js webpack-dev.config.js
    new file mode 100644
    index 0000000000..27c8e74b23
    - +  
     1var path         = require( 'path' ),
     2        SOURCE_DIR   = 'src/',
     3        mediaConfig  = {},
     4        mediaBuilds  = [ 'audiovideo', 'grid', 'models', 'views' ],
     5        webpack      = require( 'webpack' );
     6
     7
     8mediaBuilds.forEach( function ( build ) {
     9        var path = SOURCE_DIR + 'wp-includes/js/media';
     10        mediaConfig[ build ] = './' + path + '/' + build + '.manifest.js';
     11} );
     12
     13module.exports = {
     14        cache: true,
     15        watch: true,
     16        entry: mediaConfig,
     17        output: {
     18                path: path.join( __dirname, 'src/wp-includes/js' ),
     19                filename: 'media-[name].js'
     20        }
     21};
  • new file webpack.config.js

    diff --git webpack.config.js webpack.config.js
    new file mode 100644
    index 0000000000..8a0b1e4c5c
    - +  
     1var path         = require( 'path' ),
     2        SOURCE_DIR   = 'src/',
     3        mediaConfig  = {},
     4        mediaBuilds  = [ 'audiovideo', 'grid', 'models', 'views' ],
     5        webpack      = require( 'webpack' );
     6
     7
     8mediaBuilds.forEach( function ( build ) {
     9        var path = SOURCE_DIR + 'wp-includes/js/media';
     10        mediaConfig[ build ] = './' + path + '/' + build + '.manifest.js';
     11} );
     12
     13module.exports = {
     14        cache: true,
     15        entry: mediaConfig,
     16        output: {
     17                path: path.join( __dirname, 'src/wp-includes/js' ),
     18                filename: 'media-[name].js'
     19        },
     20        plugins: [
     21                new webpack.optimize.ModuleConcatenationPlugin()
     22        ]
     23};