Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 115 additions & 15 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,97 @@ module.exports = function(grunt) {
certificates: {
src: 'vendor/composer/ca-bundle/res/cacert.pem',
dest: SOURCE_DIR + 'wp-includes/certificates/ca-bundle.crt'
}
},
// Gutenberg PHP infrastructure files (routes.php, pages.php, constants.php, pages/, routes/).
'gutenberg-php': {
options: {
process: function( content ) {
// Fix boot module asset file path for Core's different directory structure.
return content.replace(
/__DIR__\s*\.\s*['"]\/..\/\..\/modules\/boot\/index\.min\.asset\.php['"]/g,
"ABSPATH . WPINC . '/js/dist/script-modules/boot/index.min.asset.php'"
);
}
},
files: [ {
expand: true,
cwd: 'gutenberg/build',
src: [
'routes.php',
'pages.php',
'constants.php',
'pages/**/*.php',
'routes/**/*.php',
],
dest: WORKING_DIR + 'wp-includes/build/',
} ],
},
'gutenberg-modules': {
files: [ {
expand: true,
cwd: 'gutenberg/build/modules',
src: [ '**/*', '!**/*.map' ],
dest: WORKING_DIR + 'wp-includes/js/dist/script-modules/',
} ],
},
'gutenberg-styles': {
files: [ {
expand: true,
cwd: 'gutenberg/build/styles',
src: [ '**/*', '!**/*.map' ],
dest: WORKING_DIR + 'wp-includes/css/dist/',
} ],
},
'gutenberg-theme-json': {
options: {
process: function( content, srcpath ) {
// Replace the local schema URL with the canonical public URL for Core.
if ( path.basename( srcpath ) === 'theme.json' ) {
return content.replace(
'"$schema": "../schemas/json/theme.json"',
'"$schema": "https://schemas.wp.org/trunk/theme.json"'
);
}
return content;
}
},
files: [
{
src: 'gutenberg/lib/theme.json',
dest: WORKING_DIR + 'wp-includes/theme.json',
},
{
src: 'gutenberg/lib/theme-i18n.json',
dest: WORKING_DIR + 'wp-includes/theme-i18n.json',
},
],
},
'gutenberg-icons': {
options: {
process: function( content, srcpath ) {
// Remove the 'gutenberg' text domain from _x() calls in manifest.php.
if ( path.basename( srcpath ) === 'manifest.php' ) {
return content.replace(
/_x\(\s*([^,]+),\s*([^,]+),\s*['"]gutenberg['"]\s*\)/g,
'_x( $1, $2 )'
);
}
return content;
}
},
files: [
{
src: 'gutenberg/packages/icons/src/manifest.php',
dest: WORKING_DIR + 'wp-includes/icons/manifest.php',
},
{
expand: true,
cwd: 'gutenberg/packages/icons/src/library',
src: '*.svg',
dest: WORKING_DIR + 'wp-includes/icons/library/',
},
],
},
},
sass: {
colors: {
Expand Down Expand Up @@ -1322,20 +1412,21 @@ module.exports = function(grunt) {
},
{
expand: true,
flatten: true,
src: [
BUILD_DIR + 'wp-includes/js/dist/block-editor.js',
BUILD_DIR + 'wp-includes/js/dist/commands.js',
],
dest: BUILD_DIR + 'wp-includes/js/dist/'
cwd: BUILD_DIR + 'wp-includes/js/dist/',
src: [ '*.js' ],
dest: BUILD_DIR + 'wp-includes/js/dist/',
},
{
expand: true,
flatten: true,
src: [
BUILD_DIR + 'wp-includes/js/dist/vendor/**/*.js'
],
dest: BUILD_DIR + 'wp-includes/js/dist/vendor/'
cwd: BUILD_DIR + 'wp-includes/js/dist/vendor/',
src: [ '**/*.js' ],
dest: BUILD_DIR + 'wp-includes/js/dist/vendor/',
},
{
expand: true,
cwd: BUILD_DIR + 'wp-includes/js/dist/script-modules/',
src: [ '**/*.js' ],
dest: BUILD_DIR + 'wp-includes/js/dist/script-modules/',
}
]
}
Expand Down Expand Up @@ -1500,7 +1591,7 @@ module.exports = function(grunt) {
} );
} );

grunt.registerTask( 'gutenberg:copy', 'Copies Gutenberg build output to WordPress Core.', function() {
grunt.registerTask( 'gutenberg:copy', 'Copies Gutenberg JS packages and block assets to WordPress Core.', function() {
const done = this.async();
const buildDir = grunt.option( 'dev' ) ? 'src' : 'build';
grunt.util.spawn( {
Expand Down Expand Up @@ -1948,14 +2039,23 @@ module.exports = function(grunt) {
} );
} );

grunt.registerTask( 'build:gutenberg', [
'copy:gutenberg-php',
'gutenberg:copy',
'copy:gutenberg-modules',
'copy:gutenberg-styles',
'copy:gutenberg-theme-json',
'copy:gutenberg-icons',
] );

grunt.registerTask( 'build', function() {
if ( grunt.option( 'dev' ) ) {
grunt.task.run( [
'gutenberg:verify',
'build:js',
'build:css',
'build:codemirror',
'gutenberg:copy',
'build:gutenberg',
'copy-vendor-scripts',
'build:certificates'
] );
Expand All @@ -1967,7 +2067,7 @@ module.exports = function(grunt) {
'build:js',
'build:css',
'build:codemirror',
'gutenberg:copy',
'build:gutenberg',
'copy-vendor-scripts',
'replace:source-maps',
'verify:build'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"wicg-inert": "3.1.3"
},
"scripts": {
"postinstall": "npm run gutenberg:download && npm run gutenberg:copy -- --dev",
"postinstall": "npm run gutenberg:download && grunt build:gutenberg --dev",
"build": "grunt build",
"build:dev": "grunt build --dev",
"dev": "grunt watch --dev",
Expand Down
Loading