admin管理员组文章数量:1317565
I grabbed gallery block from Gutenberg github (Gallery block) and I wanted to modify it in following way: only first image is output to the html, while the rest are sent to lightbox javascript plugin.
However, when compiled and used, I am getting a bunch of excess dependencies in the frontend like lodash, react, react.dom and so on. Gutenberg does not output these dependencies in the frontend.
How to prevent outputting these dependencies? they are getting outputed in index.asset.php. I am using @wordpress/create-block to work and compile with blocks.
I grabbed gallery block from Gutenberg github (Gallery block) and I wanted to modify it in following way: only first image is output to the html, while the rest are sent to lightbox javascript plugin.
However, when compiled and used, I am getting a bunch of excess dependencies in the frontend like lodash, react, react.dom and so on. Gutenberg does not output these dependencies in the frontend.
How to prevent outputting these dependencies? they are getting outputed in index.asset.php. I am using @wordpress/create-block to work and compile with blocks.
Share Improve this question edited Nov 2, 2020 at 10:20 Lovor asked Nov 2, 2020 at 9:18 LovorLovor 9969 silver badges16 bronze badges 3- Have you considered instead using the official build tools via WP Scripts? Could the change you wanted not be achieved via filters in javascript or block styles? That would avoid building a new block entirely, and make the content more portable, and your frontend JS and CSS would only need to target some HTML attributes – Tom J Nowell ♦ Commented Nov 2, 2020 at 9:54
- Sorry, my mistake, I used @wordpress/create-block, it is official package, as I understand, it uses WP Scripts. I am not using filters, because this block should co-exist with regular gallery block – Lovor Commented Nov 2, 2020 at 10:17
- I mean to say you can add a new block variation of the gallery, allowing users to select this new styles or variation. This does not replace the gallery. Jetpack manages this by adding variations for masonry galleries or tiled galleries, without introducing new blocks – Tom J Nowell ♦ Commented Nov 2, 2020 at 11:21
1 Answer
Reset to default 1It looks it was some kind of internal malfunctioning of webpack. After deleting everything from plugin directory (saving src files aside) and again installing @wordpress/create-block, the problem was solved.
本文标签: front endExcess dependencies
版权声明:本文标题:front end - Excess dependencies 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742020430a2414492.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论