Description
As of @wordpress/scripts 32.2.0, this technique for using SVG in a block no longer works and throws an error at compile/build time.
import { ReactComponent as Explode } from './explode.svg';
return (
<Explode />
);
This technique is described in the Using SVG section in the wp-scripts docs.
Instead of working, I get the following error:
ERROR in ./src/my-block/save.js 4:0-61
Module not found: Error: Can't resolve 'url-loader' in '/Users/jparis/projects/html/wp-content/plugins/my-plugin'
Step-by-step reproduction instructions
- in your block main directory (next to block.json) add a svg file.
- install
@wordpress/scripts@^32.2
- In your edit.js and/or save.js, add the code :
import { ReactComponent as Explode } from './explode.svg';
return (
<Explode />
);
- run
wp-scripts build (or wp-scripts start).
- see the error
Screenshots, screen recording, code snippet
No response
Environment info
- WordPress 7.0
- @wordpress/scripts 32.2.0
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
Description
As of
@wordpress/scripts32.2.0, this technique for using SVG in a block no longer works and throws an error at compile/build time.This technique is described in the Using SVG section in the wp-scripts docs.
Instead of working, I get the following error:
ERROR in ./src/my-block/save.js 4:0-61
Module not found: Error: Can't resolve 'url-loader' in '/Users/jparis/projects/html/wp-content/plugins/my-plugin'
Step-by-step reproduction instructions
@wordpress/scripts@^32.2wp-scripts build(orwp-scripts start).Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.