JavaScript for WordPress Forums Gutenberg Development Build Process for Gutenberg Plugin

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #114995
    Dirigible
    Participant

    I’ve been building a plugin based on the folder structure and webpack build process in the demo plugin associated with this course. It seems like as you add more blocks, the size of the compiled JS file grows way beyond what it should. Is the file pulling in a duplicate copy of components (such as RichText or MediaUpload from wp.editor) for every block? If so, is there a way to only include it once on the index file that imports all the blocks?

    At ~20 blocks in the plugin file, the corresponding JS file has gotten to be over 1MB, which seems way too large to me (or maybe I’m just used to the days where every little kb counts). At least it doesn’t affect front-end performance, but I can’t help but wonder if this is an issue inherent to Gutenberg, ESNext, or the Webpack build process?

    #115271
    Zac Gordon
    Keymaster

    Hi! Sorry for the delay here, but the bundled JS does not include the components, those are loaded by WordPress itself. The build size shouldn’t change too much by adding more blocks.

    What will be included are any packages you are loading that are not dev dependencies. You can also make sure that you are running npm run build instead of dev as it will optimize things a bit more.

    Hope that helps!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.