Skip to content

Commit

Permalink
Add support for watching block.json files when running npm run dev
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Jun 13, 2019
1 parent af57dc9 commit d49efd6
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit d49efd6

Please sign in to comment.