11/* jshint node:true */
2- /* jshint esversion: 6 */
2+ /* eslint-env es6 */
33/* globals Set */
44var webpackConfig = require ( './webpack.config' ) ;
55var installChanged = require ( 'install-changed' ) ;
@@ -175,6 +175,17 @@ module.exports = function(grunt) {
175175 banner : BANNER_TEXT ,
176176 linebreak : true
177177 } ,
178+ codemirror : {
179+ options : {
180+ linebreak : false ,
181+ banner : require ( './tools/webpack/codemirror-banner' )
182+ } ,
183+ files : {
184+ src : [
185+ WORKING_DIR + 'wp-includes/js/codemirror/codemirror.min.css'
186+ ]
187+ }
188+ } ,
178189 files : {
179190 src : [
180191 WORKING_DIR + 'wp-admin/css/*.min.css' ,
@@ -275,7 +286,7 @@ module.exports = function(grunt) {
275286 '!wp-includes/certificates/legacy-1024bit.pem' ,
276287 '!.{svn,git}' , // Exclude version control folders.
277288 '!wp-includes/version.php' , // Exclude version.php.
278- '!**/*.map' , // The build doesn't need .map files.
289+ '!{wp-admin,wp-includes,wp-content/themes/twenty*,wp-content/plugins/akismet}/ **/*.map' , // The build doesn't need .map files.
279290 '!index.php' , '!wp-admin/index.php' ,
280291 '!_index.php' , '!wp-admin/_index.php'
281292 ] ) ,
@@ -311,6 +322,33 @@ module.exports = function(grunt) {
311322 }
312323 ]
313324 } ,
325+ 'codemirror' : {
326+ options : {
327+ process : function ( content , srcpath ) {
328+ if ( srcpath . includes ( 'htmlhint.min.js' ) ) {
329+ return content + '\nif ( window.HTMLHint && window.HTMLHint.HTMLHint ) { window.HTMLHint = window.HTMLHint.HTMLHint; }' ;
330+ }
331+ return content ;
332+ }
333+ } ,
334+ files : [
335+ {
336+ [ WORKING_DIR + 'wp-includes/js/codemirror/csslint.js' ] : [ './node_modules/csslint/dist/csslint.js' ] ,
337+ [ WORKING_DIR + 'wp-includes/js/codemirror/esprima.js' ] : [ './node_modules/esprima/dist/esprima.js' ] ,
338+ [ WORKING_DIR + 'wp-includes/js/codemirror/htmlhint.js' ] : [ './node_modules/htmlhint/dist/htmlhint.min.js' ] ,
339+ [ WORKING_DIR + 'wp-includes/js/codemirror/jsonlint.js' ] : [ './node_modules/jsonlint/web/jsonlint.js' ] ,
340+ } ,
341+ {
342+ expand : true ,
343+ cwd : SOURCE_DIR + 'js/_enqueues/vendor/codemirror/' ,
344+ src : [
345+ 'fakejshint.js' ,
346+ 'htmlhint-kses.js' ,
347+ ] ,
348+ dest : WORKING_DIR + 'wp-includes/js/codemirror/'
349+ }
350+ ]
351+ } ,
314352 'vendor-js' : {
315353 files : [
316354 {
@@ -562,6 +600,22 @@ module.exports = function(grunt) {
562600 options : {
563601 compatibility : 'ie11'
564602 } ,
603+ codemirror : {
604+ files : {
605+ [ WORKING_DIR + 'wp-includes/js/codemirror/codemirror.min.css' ] : [
606+ 'node_modules/codemirror/lib/codemirror.css' ,
607+ 'node_modules/codemirror/addon/hint/show-hint.css' ,
608+ 'node_modules/codemirror/addon/lint/lint.css' ,
609+ 'node_modules/codemirror/addon/dialog/dialog.css' ,
610+ 'node_modules/codemirror/addon/display/fullscreen.css' ,
611+ 'node_modules/codemirror/addon/fold/foldgutter.css' ,
612+ 'node_modules/codemirror/addon/merge/merge.css' ,
613+ 'node_modules/codemirror/addon/scroll/simplescrollbars.css' ,
614+ 'node_modules/codemirror/addon/search/matchesonscrollbar.css' ,
615+ 'node_modules/codemirror/addon/tern/tern.css'
616+ ]
617+ }
618+ } ,
565619 core : {
566620 expand : true ,
567621 cwd : WORKING_DIR ,
@@ -871,7 +925,7 @@ module.exports = function(grunt) {
871925 'wp-includes/js/tinymce/plugins/wp*/plugin.js' ,
872926
873927 // Exceptions.
874- '!**/*.min.js' ,
928+ '!{wp-admin,wp-includes}/ **/*.min.js' ,
875929 '!wp-admin/js/custom-header.js' , // Why? We should minify this.
876930 '!wp-admin/js/farbtastic.js' ,
877931 '!wp-includes/js/wp-emoji-loader.js' , // This is a module. See the emoji-loader task below.
@@ -921,7 +975,8 @@ module.exports = function(grunt) {
921975 webpack : {
922976 prod : webpackConfig ( { environment : 'production' , buildTarget : WORKING_DIR } ) ,
923977 dev : webpackConfig ( { environment : 'development' , buildTarget : WORKING_DIR } ) ,
924- watch : webpackConfig ( { environment : 'development' , watch : true } )
978+ watch : webpackConfig ( { environment : 'development' , watch : true } ) ,
979+ codemirror : require ( './tools/webpack/codemirror.config.js' ) ( { buildTarget : WORKING_DIR } ) ,
925980 } ,
926981 concat : {
927982 tinymce : {
@@ -1652,6 +1707,13 @@ module.exports = function(grunt) {
16521707 'uglify:moment'
16531708 ] ) ;
16541709
1710+ grunt . registerTask ( 'build:codemirror' , [
1711+ 'webpack:codemirror' ,
1712+ 'cssmin:codemirror' ,
1713+ 'usebanner:codemirror' ,
1714+ 'copy:codemirror'
1715+ ] ) ;
1716+
16551717 grunt . registerTask ( 'build:webpack' , [
16561718 'clean:webpack-assets' ,
16571719 'webpack:prod' ,
@@ -1679,7 +1741,7 @@ module.exports = function(grunt) {
16791741 'cssmin:rtl' ,
16801742 'cssmin:colors' ,
16811743 'cssmin:themes' ,
1682- 'usebanner'
1744+ 'usebanner:files '
16831745 ] ) ;
16841746
16851747 grunt . registerTask ( 'certificates:upgrade-package' , 'Upgrades the package responsible for supplying the certificate authority certificate store bundled with WordPress.' , function ( ) {
@@ -1902,6 +1964,7 @@ module.exports = function(grunt) {
19021964 grunt . task . run ( [
19031965 'build:js' ,
19041966 'build:css' ,
1967+ 'build:codemirror' ,
19051968 'gutenberg-sync' ,
19061969 'gutenberg-copy' ,
19071970 'copy-vendor-scripts' ,
@@ -1913,6 +1976,7 @@ module.exports = function(grunt) {
19131976 'build:files' ,
19141977 'build:js' ,
19151978 'build:css' ,
1979+ 'build:codemirror' ,
19161980 'gutenberg-sync' ,
19171981 'gutenberg-copy' ,
19181982 'copy-vendor-scripts' ,
0 commit comments