Skip to content
Closed
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
56 changes: 36 additions & 20 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,34 @@ module.exports = function(grunt) {
'!wp-includes/js/dist/vendor/react-jsx-runtime*',
],

// Files sourced from the Gutenberg repository built asset that are ignored by version control.
/*
* Files sourced from the Gutenberg repository built asset that are ignored by version control.
*
* Paths are relative to a build root (src/ or build/). The root is applied in the
* clean:gutenberg task so these can be cleaned from src/ and/or build/ as needed.
*/
gutenbergUnversionedFiles = [
SOURCE_DIR + 'wp-includes/blocks/*/*.css',
SOURCE_DIR + 'wp-includes/css/dist',
SOURCE_DIR + 'wp-includes/js/dist/*.js',
SOURCE_DIR + 'wp-includes/js/dist/script-modules',
SOURCE_DIR + 'wp-includes/js/dist/vendor/react-jsx-runtime*',
'wp-includes/blocks/*/*.css',
'wp-includes/css/dist',
'wp-includes/js/dist/*.js',
'wp-includes/js/dist/script-modules',
'wp-includes/js/dist/vendor/react-jsx-runtime*',
],

// Files sourced from the Gutenberg repository built asset that are managed through version control.
gutenbergVersionedFiles = [
// Block assets (block.json, top-level PHP, nested PHP helpers).
SOURCE_DIR + 'wp-includes/blocks/*',
'!' + SOURCE_DIR + 'wp-includes/blocks/index.php',
SOURCE_DIR + 'wp-includes/images/icon-library',
SOURCE_DIR + 'wp-includes/theme.json',
SOURCE_DIR + 'wp-includes/theme-i18n.json',
'wp-includes/blocks/*',
'!wp-includes/blocks/index.php',
'wp-includes/images/icon-library',
'wp-includes/theme.json',
'wp-includes/theme-i18n.json',
// Routes and pages.
SOURCE_DIR + 'wp-includes/build',
'wp-includes/build',
// PHP manifests generated by gutenberg:copy.
SOURCE_DIR + 'wp-includes/assets/icon-library-manifest.php',
SOURCE_DIR + 'wp-includes/assets/script-loader-packages.php',
SOURCE_DIR + 'wp-includes/assets/script-modules-packages.php',
'wp-includes/assets/icon-library-manifest.php',
'wp-includes/assets/script-loader-packages.php',
'wp-includes/assets/script-modules-packages.php',
],

// All files built by Webpack, in /src or /build.
Expand Down Expand Up @@ -275,6 +280,9 @@ module.exports = function(grunt) {
*
* When `clean:gutenberg` is not explicitly called and run through `grunt clean`, only ignored files are
* cleaned.
*
* Gutenberg-sourced files are always cleaned from src/. For production builds (no --dev), they are also
* cleaned from build/ so that files removed upstream do not linger there if a previous build copied them.
*/
gutenberg: {
get src() {
Expand All @@ -284,11 +292,19 @@ module.exports = function(grunt) {
cli.includes( 'clean' ) &&
! cli.includes( 'clean:gutenberg' );

if ( isBareCleanSweep ) {
return gutenbergUnversionedFiles;
} else {
return gutenbergUnversionedFiles.concat( gutenbergVersionedFiles );
}
const fileList = isBareCleanSweep
? gutenbergUnversionedFiles
: gutenbergUnversionedFiles.concat( gutenbergVersionedFiles );

const targetDirs = grunt.option( 'dev' )
? [ SOURCE_DIR ]
: [ SOURCE_DIR, BUILD_DIR ];

return targetDirs.flatMap( function( dir ) {
return fileList.map( function( file ) {
return setFilePath( dir, file );
} );
} );
},
},

Expand Down
Loading