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

Not really an issue, just something I tried. #1

Open
milesaylward opened this issue Oct 19, 2021 · 0 comments
Open

Not really an issue, just something I tried. #1

milesaylward opened this issue Oct 19, 2021 · 0 comments

Comments

@milesaylward
Copy link

milesaylward commented Oct 19, 2021

First off thank you, I have been working in Gutenberg building a custom theme and blocks for the first time and my biggest grievance was not having an easy way to have multiple blocks without having multiple "npm start:BLOCK_NAME": "wp-scripts start LONG_PATH" --output LONG_PATH. So your repo was a god send for me! Small enhancement I found useful so I only had to add to the array in PHP and re run npm start was to change the entries in webpack config. I believe WP scripts already comes with glob.

const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const glob = require('glob');

function getEntries() {
    const out = {};
    glob.sync("./src/block-library/**/index.js").forEach(entry => {
        out[entry.split('/')[2]] = entry;
    });
    return out;
};

module.exports = {
    ...defaultConfig,
    entry: getEntries,
}

Thanks again for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant