Skip to content

Commit

Permalink
Account for multiple js files in blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
rsefer committed Jul 26, 2023
1 parent 1f999c1 commit 69c7990
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/blocks.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { promises as fs } from 'fs';
import path from 'path';
import project from '../lib/project.js';
import log from './logging.js';
Expand Down Expand Up @@ -43,7 +44,11 @@ const buildBlock = async (entry) => {
return false;
}
let timerStart = Date.now();
await cmd(`cd ${entry} && ${project.path}/node_modules/@wordpress/scripts/bin/wp-scripts.js`, 'build', 'src/index');
let cmds = [`build`];
for (var file of (await fs.readdir(`${entry}/src`)).filter(file => path.extname(file) == '.js')) {
cmds.push(`src/${file}`);
}
await cmd(`cd ${entry} && ${project.path}/node_modules/@wordpress/scripts/bin/wp-scripts.js`, ...cmds);
log('success', `Built ${entry.replace(project.path, '')} in ${Date.now() - timerStart}ms`);
};

Expand Down

0 comments on commit 69c7990

Please sign in to comment.