create-guten-block
create-guten-block copied to clipboard
can only edit block one time
I can only make changes to the js of the block one time. I think I must be missing a step in my development process.
npx create-guten-block my-block
cd my-block
npm start
make edits
^c
npm run build
block appears in the editor and on the page with any edits I made.
npm start
make edits
^c
npm run build
block appears the same as before without the edits I made.
what do I need to do so that my second round of edits will be built into the block?
Could be browser or caching / environment related. Are you refreshing the browser page? There is no hot module replacement in CGB currently.
I am refreshing the browser page and emptying the cache so idk what the issue is. Although I have written several plugins in PHP, my react experience so far is mostly this. Am I using the commands correctly or should I be running one to clean the npm building cache or something because that seems to be the missing piece. Unless I have to eject the block first before I can edit and rebuild it?
I'm experiencing a similar issue @brothman01 - I can make updates the the original block that was generated by CGB, and those changes are reflected. However, if I create a second block, and include it in the blocks.js (using import
) – for some reason I can never get the second block to appear.
Worth mentioning that this was all working a few months back, so I wonder if a WordPress version change is the culprit.
Feel free to send in PRs to fix this.
@ahmadawais I'll dig around and see if I can sort it, and if I can I will submit. Thanks for your efforts with CGB!
Any news on this one? I still have the issue.
This seems to be a caching issue. Not sure if its browser or WP, but a quick hack is adding cache busting to wp_register_script by adding the current time as a url var:
plugins_url( '/dist/blocks.build.js?'.time(), dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.