Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for watching block.json files when running npm run dev #16150

Merged
merged 6 commits into from
Jun 26, 2019
Merged
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ const BUILD_TASK_BY_EXTENSION = {
] );
}
},

async '.json'( file ) {
// Currently, only building block library block.json files is supported.
// See https://github.com/WordPress/gutenberg/issues/16104 for further info.
if ( ! /block-library.*block\.json$/.test( file ) ) {
return;
}

// The block.json file is inlined into the block's index.js when building.
// The following code rebuilds the index.js relative to the block.json so
// that this inlining happens again.
const blockIndexFile = file.replace( 'block.json', 'index.js' );
const task = BUILD_TASK_BY_EXTENSION[ '.js' ];
await task( blockIndexFile );
},
};

module.exports = async ( file, callback ) => {
Expand Down