Build tinymce.js.gz using grunt.
props azaozz. see #25159. git-svn-id: https://develop.svn.wordpress.org/trunk@25188 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fdafa8b480
commit
2b1b8427e7
64
Gruntfile.js
64
Gruntfile.js
@ -14,6 +14,13 @@ module.exports = function(grunt) {
|
||||
cwd: BUILD_DIR,
|
||||
src: []
|
||||
},
|
||||
tinymce: {
|
||||
src: [
|
||||
'<%= concat.tinymce.dest %>',
|
||||
BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce-schema.min.js',
|
||||
BUILD_DIR + 'wp-includes/js/tinymce/mark_loaded.js'
|
||||
]
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
all: {
|
||||
@ -68,6 +75,7 @@ module.exports = function(grunt) {
|
||||
'wp-includes/js/plupload/handlers.js',
|
||||
'wp-includes/js/plupload/wp-plupload.js',
|
||||
'wp-includes/js/tinymce/plugins/wp*/js/*.js',
|
||||
'wp-includes/js/tinymce/wp-tinymce-schema.js',
|
||||
// Exceptions
|
||||
'!wp-admin/js/custom-header.js', // Why? We should minify this.
|
||||
'!wp-admin/js/farbtastic.js',
|
||||
@ -75,7 +83,9 @@ module.exports = function(grunt) {
|
||||
'!wp-includes/js/backbone.min.js',
|
||||
'!wp-includes/js/swfobject.js',
|
||||
'!wp-includes/js/underscore.min.js',
|
||||
'!wp-includes/js/zxcvbn.min.js'
|
||||
'!wp-includes/js/zxcvbn.min.js',
|
||||
// Hard-coded in editimage.html
|
||||
'!wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js'
|
||||
]
|
||||
},
|
||||
tinymce: {
|
||||
@ -84,16 +94,46 @@ module.exports = function(grunt) {
|
||||
dest: BUILD_DIR,
|
||||
src: [
|
||||
'wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js',
|
||||
'wp-includes/js/tinymce/plugins/wp*/editor_plugin_src.js'
|
||||
'wp-includes/js/tinymce/plugins/wp*/editor_plugin_src.js',
|
||||
'wp-includes/js/tinymce/mark_loaded_src.js'
|
||||
],
|
||||
// TinyMCE plugins use a nonstandard naming scheme: plugin files are named
|
||||
// `editor_plugin_src.js`, and are compressed into `editor_plugin.js`.
|
||||
rename: function(destBase, destPath) {
|
||||
destPath = destPath.replace('/editor_plugin_src.js', '/editor_plugin.js');
|
||||
destPath = destPath.replace(/_src.js$/, '.js');
|
||||
return path.join(destBase || '', destPath);
|
||||
}
|
||||
}
|
||||
},
|
||||
concat: {
|
||||
tinymce: {
|
||||
options: {
|
||||
separator: '\n',
|
||||
banner: '// Created: <%= grunt.template.today("UTC:yyyy-mm-dd HH:MM:ss Z") %>\n',
|
||||
process: function( src, filepath ) {
|
||||
return '// Source: ' + filepath.replace( BUILD_DIR, '' ) + '\n' + src;
|
||||
}
|
||||
},
|
||||
src: [
|
||||
BUILD_DIR + 'wp-includes/js/tinymce/tiny_mce.js',
|
||||
BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce-schema.min.js',
|
||||
BUILD_DIR + 'wp-includes/js/tinymce/themes/advanced/editor_template.js',
|
||||
BUILD_DIR + 'wp-includes/js/tinymce/plugins/*/editor_plugin.js',
|
||||
BUILD_DIR + 'wp-includes/js/tinymce/mark_loaded.js'
|
||||
],
|
||||
dest: BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce.js'
|
||||
}
|
||||
},
|
||||
compress: {
|
||||
tinymce: {
|
||||
options: {
|
||||
mode: 'gzip',
|
||||
level: 9
|
||||
},
|
||||
src: '<%= concat.tinymce.dest %>',
|
||||
dest: BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce.js.gz'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
all: {
|
||||
files: [
|
||||
@ -122,10 +162,12 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-compress');
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
|
||||
// Register tasks.
|
||||
grunt.registerTask('build', ['clean:all', 'copy:all', 'cssmin:core',
|
||||
'uglify:core', 'uglify:tinymce']);
|
||||
grunt.registerTask('build', ['clean:all', 'copy:all', 'cssmin:core', 'uglify:core',
|
||||
'uglify:tinymce', 'concat:tinymce', 'compress:tinymce', 'clean:tinymce']);
|
||||
|
||||
// Testing task.
|
||||
grunt.registerTask('test', ['qunit']);
|
||||
@ -137,12 +179,14 @@ module.exports = function(grunt) {
|
||||
//
|
||||
// On `watch:all`, automatically updates the `copy:dynamic` and `clean:dynamic`
|
||||
// configurations so that only the changed files are updated.
|
||||
grunt.event.on('watch', function(action, filepath, target) {
|
||||
if (target != 'all') return;
|
||||
grunt.event.on('watch', function( action, filepath, target ) {
|
||||
if ( target != 'all' )
|
||||
return;
|
||||
|
||||
var relativePath = path.relative( SOURCE_DIR, filepath );
|
||||
var cleanSrc = ( action == 'deleted' ) ? [relativePath] : [];
|
||||
var copySrc = ( action == 'deleted' ) ? [] : [relativePath];
|
||||
|
||||
var relativePath = path.relative(SOURCE_DIR, filepath);
|
||||
var cleanSrc = (action == 'deleted') ? [relativePath] : [];
|
||||
var copySrc = (action == 'deleted') ? [] : [relativePath];
|
||||
grunt.config(['clean', 'dynamic', 'src'], cleanSrc);
|
||||
grunt.config(['copy', 'dynamic', 'src'], copySrc);
|
||||
});
|
||||
|
@ -15,6 +15,8 @@
|
||||
"grunt-contrib-cssmin": "~0.6.1",
|
||||
"grunt-contrib-qunit": "~0.2.2",
|
||||
"grunt-contrib-uglify": "~0.2.2",
|
||||
"grunt-contrib-watch": "~0.5.1"
|
||||
"grunt-contrib-watch": "~0.5.1",
|
||||
"grunt-contrib-compress": "~0.5.2",
|
||||
"grunt-contrib-concat": "~0.3.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user