I am following the official WordPress "Create a Block Tutorial" located here: https://developer.wordpress.org/block-editor/handbook/tutorials/create-block/
I used this as a starting point for the plugin: npx @wordpress/create-block
I am using it in conjunction with Local by Flywheel for my dev environment. Mostly everything seems to be working except when I try to include other files in the block's CSS like a custom font file or an image. This is part of the tutorial: https://developer.wordpress.org/block-editor/handbook/tutorials/create-block/block-code/
Example:
@font-face {
font-family: Gilbert;
src: url(./Gilbert-color.otf);
font-weight: bold;
}
.wp-block-create-block-tdblocks {
font-family: Gilbert;
font-size: 64px;
font-weight: bold;
background-image: url(./map_bg.png);
background-repeat: repeat;
}
So after I insert the recommended code and run npm run build, the css file generated by the build process leaves the links to these files relative to the current web page's URL and not a link to its file location in the proper plugin folder.
Here is what it gives me for the image file for instance (which shows as a 404 error naturally):
https://taylor-design-starter-theme.local/sample-page/images/map_bg.f0104819.png
I'd expect it to give me this:
https://taylor-design-starter-theme.local/wp-content/plugins/tdblocks/build/images/map_bg.f0104819.png
I have tried adjusting the "url" value in the scss file to see if that would help. Like src: url(../map_bg.png); or src: url(map_bg.png); and that didn't seem to do anything.
Am I missing something? Or is there a way to get it to use the plugin directory?
Thank you.
EDIT: Here is the CSS generated by the build process when I run npm run build
@font-face{font-family:Gilbert;font-weight:700;src:url(fonts/Gilbert-color.02d3d364.otf)}.wp-block-create-block-tdblocks{background-image:url(images/map_bg.f0104819.png);background-repeat:repeat;font-family:sans-serif;font-size:64px;font-weight:700}
./come from? I don't see it or the bg image in the linked tutorialplugins-muit would all break with absolute URLs