Make WordPress Core

Changeset 25188


Ignore:
Timestamp:
08/30/2013 10:16:43 PM (11 years ago)
Author:
nacin
Message:

Build tinymce.js.gz using grunt.

props azaozz.
see #25159.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r25178 r25188  
    1515                src: []
    1616            },
     17            tinymce: {
     18                src: [
     19                    '<%= concat.tinymce.dest %>',
     20                    BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce-schema.min.js',
     21                    BUILD_DIR + 'wp-includes/js/tinymce/mark_loaded.js'
     22                ]
     23            }
    1724        },
    1825        copy: {
     
    6976                    'wp-includes/js/plupload/wp-plupload.js',
    7077                    'wp-includes/js/tinymce/plugins/wp*/js/*.js',
     78                    'wp-includes/js/tinymce/wp-tinymce-schema.js',
    7179                    // Exceptions
    7280                    '!wp-admin/js/custom-header.js', // Why? We should minify this.
     
    7684                    '!wp-includes/js/swfobject.js',
    7785                    '!wp-includes/js/underscore.min.js',
    78                     '!wp-includes/js/zxcvbn.min.js'
     86                    '!wp-includes/js/zxcvbn.min.js',
     87                    // Hard-coded in editimage.html
     88                    '!wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js'
    7989                ]
    8090            },
     
    8595                src: [
    8696                    'wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js',
    87                     'wp-includes/js/tinymce/plugins/wp*/editor_plugin_src.js'
     97                    'wp-includes/js/tinymce/plugins/wp*/editor_plugin_src.js',
     98                    'wp-includes/js/tinymce/mark_loaded_src.js'
    8899                ],
    89100                // TinyMCE plugins use a nonstandard naming scheme: plugin files are named
    90101                // `editor_plugin_src.js`, and are compressed into `editor_plugin.js`.
    91102                rename: function(destBase, destPath) {
    92                     destPath = destPath.replace('/editor_plugin_src.js', '/editor_plugin.js');
     103                    destPath = destPath.replace(/_src.js$/, '.js');
    93104                    return path.join(destBase || '', destPath);
    94105                }
     106            }
     107        },
     108        concat: {
     109            tinymce: {
     110                options: {
     111                    separator: '\n',
     112                    banner: '// Created: <%= grunt.template.today("UTC:yyyy-mm-dd HH:MM:ss Z") %>\n',
     113                    process: function( src, filepath ) {
     114                        return '// Source: ' + filepath.replace( BUILD_DIR, '' ) + '\n' + src;
     115                    }
     116                },
     117                src: [
     118                    BUILD_DIR + 'wp-includes/js/tinymce/tiny_mce.js',
     119                    BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce-schema.min.js',
     120                    BUILD_DIR + 'wp-includes/js/tinymce/themes/advanced/editor_template.js',
     121                    BUILD_DIR + 'wp-includes/js/tinymce/plugins/*/editor_plugin.js',
     122                    BUILD_DIR + 'wp-includes/js/tinymce/mark_loaded.js'
     123                ],
     124                dest: BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce.js'
     125            }
     126        },
     127        compress: {
     128            tinymce: {
     129                options: {
     130                    mode: 'gzip',
     131                    level: 9
     132                },
     133                src: '<%= concat.tinymce.dest %>',
     134                dest: BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce.js.gz'
    95135            }
    96136        },
     
    123163    grunt.loadNpmTasks('grunt-contrib-uglify');
    124164    grunt.loadNpmTasks('grunt-contrib-watch');
     165    grunt.loadNpmTasks('grunt-contrib-compress');
     166    grunt.loadNpmTasks('grunt-contrib-concat');
    125167
    126168    // Register tasks.
    127     grunt.registerTask('build', ['clean:all', 'copy:all', 'cssmin:core',
    128         'uglify:core', 'uglify:tinymce']);
     169    grunt.registerTask('build', ['clean:all', 'copy:all', 'cssmin:core', 'uglify:core',
     170        'uglify:tinymce', 'concat:tinymce', 'compress:tinymce', 'clean:tinymce']);
    129171
    130172    // Testing task.
     
    138180    // On `watch:all`, automatically updates the `copy:dynamic` and `clean:dynamic`
    139181    // configurations so that only the changed files are updated.
    140     grunt.event.on('watch', function(action, filepath, target) {
    141         if (target != 'all') return;
     182    grunt.event.on('watch', function( action, filepath, target ) {
     183        if ( target != 'all' )
     184            return;
    142185
    143         var relativePath = path.relative(SOURCE_DIR, filepath);
    144         var cleanSrc = (action == 'deleted') ? [relativePath] : [];
    145         var copySrc = (action == 'deleted') ? [] : [relativePath];
     186        var relativePath = path.relative( SOURCE_DIR, filepath );
     187        var cleanSrc = ( action == 'deleted' ) ? [relativePath] : [];
     188        var copySrc = ( action == 'deleted' ) ? [] : [relativePath];
     189
    146190        grunt.config(['clean', 'dynamic', 'src'], cleanSrc);
    147191        grunt.config(['copy', 'dynamic', 'src'], copySrc);
  • trunk/package.json

    r25178 r25188  
    1616    "grunt-contrib-qunit": "~0.2.2",
    1717    "grunt-contrib-uglify": "~0.2.2",
    18     "grunt-contrib-watch": "~0.5.1"
     18    "grunt-contrib-watch": "~0.5.1",
     19    "grunt-contrib-compress": "~0.5.2",
     20    "grunt-contrib-concat": "~0.3.0"
    1921  }
    2022}
Note: See TracChangeset for help on using the changeset viewer.