nuxt-community / svg-module

Super simple svg loading module for Nuxt.js
MIT License
340 stars 35 forks source link

Unexpected '.svg' #5

Closed vukadinFE closed 5 years ago

vukadinFE commented 5 years ago

Hi, Thanks for awesome module. I've found it useful and I am using it on every nuxt project. 👍

One thing is bothering me. Every time I make changes to nuxt.config.js file, ERROR: nuxt-svg: Unexpected '.svg' rule in the webpack configuration shows in CLI and I have to restart local server in order to continue with work. Do you have any idea what could be a problem?

sam3d commented 5 years ago

I'm very glad you like it so much! I'm sorry you're having this issue.

I think this could have something to do with #1 that checks if the rule has already been applied:

https://github.com/sam3d/nuxt-svg/blob/411c8c4a83a11e9896a8a72e878613389e83fb04/module.js#L26-L30

The error will only show in the following two conditions:

  1. If the rule does not equal the Nuxt.js default rule (if it's changed upstream), and
  2. The rule does not equal the new rule that this module sets

I don't know what else it would be getting changed to during hot-reload, so I'll have to look into this a little more. Please could you help me out by creating a very simple repository that reproduces this bug after the steps you've described? Thanks!

vukadinFE commented 5 years ago

I have tried to reproduce this error on new repository keeping the same package.json. I had no luck, which is good.

So I have reinstalled node_modules on 2 projects where this error appeared and that solved my problem. It's not so strange, because I installed node_modules on both projects same day. It might be some problem with yarn that day. Who knows? :)

sam3d commented 5 years ago

Huh, weird! It must've been a weird dependency issue with whichever lockfile you were using. Either way, I'm closing this issue unless it surfaces reproducibly again.

Thank you for trying it again so we can close this issue :)

laSinteZ commented 5 years ago

That's strange because I had exactly same problem and now it's gone for me as well. image

tiendatleo commented 5 years ago

I have same issue

Rednas83 commented 5 years ago

I also have the same error

(node:12592) UnhandledPromiseRejectionWarning: Error: nuxt-svg: Unexpected '.svg' rule in the webpack configuration
    at WebpackBundler.setup (C:\Cloud Files\Projecten\Project1\node_modules\@nuxtjs\svg\lib\module.js:30:13)
    at WebpackBundler.<anonymous> (C:\Cloud Files\Projecten\Project1\node_modules\@nuxt\utils\dist\utils.js:1824:25)
    at WebpackClientConfig.extendConfig (C:\Cloud Files\Projecten\Project1\node_modules\@nuxt\webpack\dist\webpack.js:4738:37)
    at WebpackClientConfig.config (C:\Cloud Files\Projecten\Project1\node_modules\@nuxt\webpack\dist\webpack.js:4773:45)
    at WebpackClientConfig.config (C:\Cloud Files\Projecten\Project1\node_modules\@nuxt\webpack\dist\webpack.js:4925:26)
    at WebpackBundler.getWebpackConfig (C:\Cloud Files\Projecten\Project1\node_modules\@nuxt\webpack\dist\webpack.js:5203:19)
    at WebpackBundler.build (C:\Cloud Files\Projecten\Project1\node_modules\@nuxt\webpack\dist\webpack.js:5210:12)
    at Builder.build (C:\Cloud Files\Projecten\Project1\node_modules\@nuxt\builder\dist\builder.js:5597:30)
    at async start (C:\Cloud Files\Projecten\Project1\server\index.js:23:5)
(node:12592) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:12592) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero 
exit code.

Tried:

  1. Re-installing all node_modules
  2. Updating to the latest version of yarn, node, node_modules, etc...
    "dependencies": {
        "@nuxtjs/axios": "^5.6.0",
        "@nuxtjs/pwa": "^3.0.0-beta.19",
        "@nuxtjs/svg": "^0.1.6",
        "cross-env": "^6.0.3",
        "koa": "^2.10.0",
        "nuxt": "^2.10.1",
        "nuxt-buefy": "^0.3.16",
        "vue-svg-loader": "^0.12.0",
        "vue-template-compiler": "^2.6.10"
    },
    "devDependencies": {
        "@vue/test-utils": "^1.0.0-beta.29",
        "babel-jest": "^24.9.0",
        "eslint-config-prettier": "^6.4.0",
        "eslint-plugin-prettier": "^3.1.1",
        "jest": "^24.9.0",
        "nodemon": "^1.19.4",
        "prettier": "^1.18.2",
        "vue-jest": "^3.0.5"
    }

    Anyone has as fix? Perhaps reopen the issue?

Cobertos commented 4 years ago

Getting this as well image

For me, I believe this is because I'm using nuxt-responsive-loader which does Webpack rule editing as well. Unfortunately the two are incompatible according to their documentation.

Saamiyah commented 4 years ago

I am having the same issue

image

Rednas83 commented 4 years ago

I switched to nuxt-svg-loader and that is working for me https://github.com/Developmint/nuxt-svg-loader