0

I have a theme that is live and has some 10-20 custom gutenberg blocks, Those blocks sometime have svg imported to them like so

import logo from './logo.svg'

Today when I was trying to work and compile the theme getting an error in the SVGR plugin that comes with wp-scripts when ever I try to import any SVG to the block,

This worked fine 2 days ago.

Here is my package.json file.

{
  "name": "some-project",
  "version": "1.0.0",
  "description": "A project for...",
  "main": "build/index.js",
  "scripts": {
    "build:scripts": "wp-scripts build",
    "start-build": "wp-scripts start",
    "lint:js": "wp-scripts lint-js",
    "lint:js:src": "wp-scripts lint-js ./src"
  },
  "author": "",
  "license": "UNLICENSED",
  "repository": {},
  "private": true,
  "devDependencies": {
    "@lottiefiles/lottie-player": "1.5.7",
    "@popperjs/core": "2.11.5",
    "@svgr/webpack": "^6.5.1",
    "@wordpress/scripts": "^24.2.0",
    "bootstrap": "5.1.3",
    "eslint": "^8.34.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "flickity": "3.0.0",
    "jquery": "3.6.0",
    "lity": "2.4.1",
    "lodash": "4.17.21",
    "lodash.assign": "4.2.0",
    "prettier": "2.7.1",
    "typescript": "^4.7.4",
    "url-loader": "^4.1.1"
  },
  "dependencies": {
    "build": "^0.1.4",
    "eslint-config-wordpress": "^2.0.0",
    "wp-scripts": "^0.0.1-security"
  }
}

Would love some help.

My

3
  • you forgot to share the error you were getting, can you edit it into your question?
    – Tom J Nowell
    Commented Feb 21, 2023 at 21:05
  • I'm having the same issue with couple of themes I worked on, this is the error I see Module build failed (from ./node_modules/@svgr/webpack/dist/index.js): Error: Plugin name should be specified
    – AlonK
    Commented Sep 4, 2023 at 21:51
  • Your package file references wp-scripts but that's not the name of the package, and wp-scripts was taken down for security reasons by NPM. @wordpress/scripts is the correct package, and at the moment is on v26 not the v24 you've used. I also see that you've explicitly used "@svgr/webpack": "^6.5.1", in your package file which is very strange since you should be using the one that comes with @wordpress/scripts instead for better compatibility. Likewise a lot of the other dependencies are unnecessary
    – Tom J Nowell
    Commented Sep 5, 2023 at 12:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.