Closed alexdelgado closed 2 years ago
It is worth noting the work-around for anyone who doesn't want to put block.json
in the src
folder can create a webpack.config.js
file in the root of the block directory and set the entries manually.
const defaultConfig = require('@wordpress/scripts/config/webpack.config')
module.exports = {
...defaultConfig,
entry: {
index: './src/index.js',
view: './src/view.js'
}
}
Hello and thanks for taking the time to open this issue!
This is probably better discussed in https://github.com/WordPress/gutenberg/issues/40771 as this repo is meant to store examples and simply uses the APIs provided. I'll add my comments there 😄
@alexdelgado based on the conversation in https://github.com/WordPress/gutenberg/issues/40771, I'm going to close this out. Please feel free to reopen if I have missed something. Thanks again for opening it!
I've just submitted an issue to the Gutenberg repo regarding the placement of
block.json
because it's not very clear that when you use a custom entry-point or multiple entry points such as "editorScript" or "viewScript" webpack expects block.json to live inside thesrc
folder. In all your examples where there is asrc
folder,block.json
is not inside that folder which is confusing unless you realize that works because in all the examples you are using the default entry point ofsrc/index.js
.Additionally, if you did move
block.json
into thesrc
folder per the webpack config, it would look forsrc/build/index.js
instead ofsrc/index.js
, because thefile:...
path is relative to thesrc
directory, not the package directory.I'm raising this issue here as well as Gutenberg because I believe
block.json
shouldn't live insidesrc
but also because:file:...
values are technically incorrect but it's not being caught because wepack uses the default entry point ofsrc/index.js