Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Clean the top-level of the /build folder #6972

Closed
tarhi-saad opened this issue Aug 24, 2022 · 1 comment · Fixed by #7047
Closed

Clean the top-level of the /build folder #6972

tarhi-saad opened this issue Aug 24, 2022 · 1 comment · Fixed by #7047
Assignees
Labels
tools Used for work on build or release tools. type: cooldown Things that are queued for a cooldown period (assists with planning). type: refactor The issue/PR is related to refactoring.

Comments

@tarhi-saad
Copy link
Contributor

After the changes introduced in the #6737 PR, the /build folder is currently polluted with so many top-level folders. To fix this, we can choose to generate the Inner Blocks blocks.json files inside a parent folder (e.g., /checkout-blocks and /cart-blocks).

This is the code block to update:

from: './assets/js/blocks/**/block.json',
to( { absoluteFilename } ) {
/**
* Getting the block name from the JSON metadata is less error prone
* than extracting it from the file path.
*/
const JSONFile = fs.readFileSync(
path.resolve( __dirname, absoluteFilename )
);
const metadata = JSON.parse( JSONFile.toString() );
const blockName = metadata.name
.split( '/' )
.at( 1 );
return `./${ blockName }/block.json`;

image

@tarhi-saad tarhi-saad added tools Used for work on build or release tools. type: cooldown Things that are queued for a cooldown period (assists with planning). labels Aug 24, 2022
@tarhi-saad tarhi-saad self-assigned this Aug 24, 2022
@senadir
Copy link
Member

senadir commented Sep 2, 2022

This fix wouldn't affect JS translation loading (only concerns PHP translation loading) so it's fine to fix without backward compatibility.

@tarhi-saad tarhi-saad added the type: refactor The issue/PR is related to refactoring. label Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tools Used for work on build or release tools. type: cooldown Things that are queued for a cooldown period (assists with planning). type: refactor The issue/PR is related to refactoring.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants