Skip to content

Commit

Permalink
[MOOSE-86]: rewrite block entry points to apply view files
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffDusome committed Mar 5, 2024
1 parent 45660c3 commit 237b64e
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,31 @@ const assetEntryPoints = () => {
*/
const blockEntryPoints = () => {
/**
* Use `index.js` instead of `block.json` for glob b/c core blocks won't
* contain a `block.json` file (they are already registered), but they
* still may contain scripts or styles which should be processed.
* Create files array using index.js, editor.js and view.js files
*
* We use `index.js` instead of `block.json` for glob b/c core blocks
* won't contain a `block.json` file (they are already registered),
* but they still may contain scripts or styles which should be processed.
*/
const coreBlockFiles = glob(
`${ pkg.config.coreThemeBlocksDir }/**/index.js`,
{ absolute: true }
);

const coreBlockEditorFiles = glob(
`${ pkg.config.coreThemeBlocksDir }/**/editor.js`,
{ absolute: true }
);
const files = [
...glob( `${ pkg.config.coreThemeBlocksDir }/**/index.js`, {
absolute: true,
} ),
...glob( `${ pkg.config.coreThemeBlocksDir }/**/editor.js`, {
absolute: true,
} ),
...glob( `${ pkg.config.coreThemeBlocksDir }/**/view.js`, {
absolute: true,
} ),
];

if ( ! coreBlockFiles.length && ! coreBlockEditorFiles.length ) {
if ( ! files.length ) {
return;
}

const entryPoints = {};

coreBlockFiles.forEach( ( entryFilePath ) => {
const entryName = entryFilePath
.replace( extname( entryFilePath ), '' )
.replace( `${ resolve( pkg.config.coreThemeDir ) }/`, '' );
entryPoints[ entryName ] = entryFilePath;
} );

coreBlockEditorFiles.forEach( ( entryFilePath ) => {
files.forEach( ( entryFilePath ) => {
const entryName = entryFilePath
.replace( extname( entryFilePath ), '' )
.replace( `${ resolve( pkg.config.coreThemeDir ) }/`, '' );
Expand Down

0 comments on commit 237b64e

Please sign in to comment.