Coder Social home page Coder Social logo

nuxt-svg-loader's People

Contributors

3b3ziz avatar anaphase avatar andrewbogdanovtss avatar bazuka5801 avatar mannil avatar mrleblanc101 avatar renovate-bot avatar renovate[bot] avatar wagerfield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nuxt-svg-loader's Issues

Typescript support?

I'm using nuxt with typescript (nuxt-property-decorator), when import svg:

<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
import Logo from '@/assets/svg/logo.svg'

@Component({
  components: {
    Logo
  }
})
class Def extends Vue {}
export default Def
</script>

I'm getting error: Cannot find module '@/assets/svg/logo.svg'.Vetur(2307)

Using svg as background-image does not work

When you use the default options and rules given here, svg paths cannot be used in CSS background-image: url() anymore.

Example:

background-image: url('~/assets/some-icon.svg')

Output

background-image: url('[Object object]')

Expected

background-image: url("data:image/svg+xml;utf8,<svg> optimized svg </svg>");

This would require https://github.com/bhovhannes/svg-url-loader to work

The webpack config could then look like that, I tried to make it work locally, but somehow the resulting SVG data gets escaped (guess this is some kind of nuxt XSS protection).

config.module.rules.push({
  test: /\.svg$/,
  oneOf: [
    {
      resourceQuery: /css/,
      use: {
        loader: 'svg-url-loader',
        options: { noquotes: false }
      }
    },
    {
      use: [
        'vue-loader',
        {
          loader: 'svg-to-vue-component/loader',
          options
        }
      ]
    }
  ]
})

You could use it then like this:

background-image: url('~/assets/some-icon.svg?css')

Feature: accept module options

This doesn't work

modules: [
    ["nuxt-svg-loader", { svgoConfig: false }]
],

But this works:

modules: [ "nuxt-svg-loader" ],
svgLoader: { svgoConfig: false },

Bug or by design?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update devdependency eslint to v9
  • chore(deps): update devdependency eslint-plugin-jest to v28
  • chore(deps): update devdependency eslint-plugin-promise to v6
  • chore(deps): update devdependency eslint-plugin-standard to v5
  • chore(deps): update devdependency eslint-plugin-vue to v9
  • chore(deps): update devdependency get-port to v7
  • chore(deps): update devdependency husky to v9
  • chore(deps): update devdependency jsdom to v24
  • chore(deps): update node.js to v20
  • chore(deps): update npm to v10
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • consola ^2.3.2
  • svg-to-vue-component ^0.3.1
  • @commitlint/cli ^7.3.1
  • @commitlint/config-conventional ^7.3.1
  • @nuxtjs/eslint-config ^0.0.1
  • babel-eslint ^10.0.1
  • codecov ^3.1.0
  • eslint ^5.12.0
  • eslint-config-standard ^12.0.0
  • eslint-plugin-import ^2.14.0
  • eslint-plugin-jest ^22.1.3
  • eslint-plugin-node ^8.0.1
  • eslint-plugin-promise ^4.0.1
  • eslint-plugin-standard ^4.0.0
  • eslint-plugin-vue ^5.1.0
  • get-port ^4.1.0
  • husky ^1.3.1
  • jest ^23.6.0
  • jsdom ^13.1.0
  • nuxt-edge ^2.4.0-25786640.3ebd6b70
  • standard-version ^4.4.0
  • node >=8.0.0
  • npm >=5.0.0
travis
.travis.yml
  • node 8
  • node 9
  • node 10

  • Check this box to trigger a request for Renovate to run again on this repository

[feature request] Auto-load SVG components

Hey!
With Nuxt 2.13, we can auto-load components. I tried auto-loading the SVG components like this in nuxt.config.js

  components: {
    extensions: ['vue', 'svg']
  }

But it doesn't work. (I put the SVG files in the components directory).

It would be great if SVG components were auto-loaded like regular Vue components! ๐Ÿ˜€

Load the SVG into a dynamic component

Hi ! ๐Ÿ‘‹๐Ÿป
I was wondering if that kind of code may work <component is="svg-grey-home"></component>.

Because we have Nuxt components now, so maybe it is possible in any way.

Without having to use

<script>
export default {
  components: {
    SvgGreyHome: () => import('~/assets/svg/grey/home.svg'),
  },
}
</script>

In my case, writting <svg-grey-home></svg-grey-home> totally works (the setup is done for that) but I want to make it dynamic without the need to import it beforehand.

StyleComponent build error

After 1.0.1 release, my builds is failing.

<tecnospeed-logo
  :class="!isFixed ? 'svgToWhite' : ''"
  width="180"
  alt="Logo da TecnoSpeed"
  class="img-fluid" />
import TecnospeedLogo from '@/assets/images/tecnospeed.svg'
export default {
  name: 'CommonNavbar',
  components: {
    /* ... */
    TecnospeedLogo
  }
}
8:40:24 PM: ERROR in ./assets/images/tecnospeed.svg?vue&type=script&lang=js& (./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib!./node_modules/svg-to-vue-component/loader.js!./assets/images/tecnospeed.svg?vue&type=script&lang=js&)
8:40:24 PM: Module build failed (from ./node_modules/babel-loader/lib/index.js):
8:40:24 PM: SyntaxError: /opt/build/repo/assets/images/tecnospeed.svg: Unexpected token (3:17)
8:40:24 PM:   1 | //
8:40:24 PM:   2 |
8:40:24 PM: > 3 | import Component "/opt/build/repo/node_modules/svg-to-vue-component/lib/StyleComponent.js"
8:40:25 PM:     |                  ^
8:40:25 PM:   4 | export default {
8:40:25 PM:   5 |   components: {
8:40:25 PM:   6 |     'svg2vue-style': Component
8:40:25 PM:     at _class.raise (/opt/build/repo/node_modules/@babel/parser/lib/index.js:4051:15)
8:40:25 PM:     at _class.unexpected (/opt/build/repo/node_modules/@babel/parser/lib/index.js:5382:16)
8:40:25 PM:     at _class.expectContextual (/opt/build/repo/node_modules/@babel/parser/lib/index.js:5350:41)
8:40:25 PM:     at _class.parseImport (/opt/build/repo/node_modules/@babel/parser/lib/index.js:8823:12)
8:40:25 PM:     at _class.parseStatementContent (/opt/build/repo/node_modules/@babel/parser/lib/index.js:7586:27)
8:40:25 PM:     at _class.parseStatement (/opt/build/repo/node_modules/@babel/parser/lib/index.js:7505:17)
8:40:25 PM:     at _class.parseBlockOrModuleBlockBody (/opt/build/repo/node_modules/@babel/parser/lib/index.js:8073:23)
8:40:25 PM:     at _class.parseBlockBody (/opt/build/repo/node_modules/@babel/parser/lib/index.js:8060:10)
8:40:25 PM:     at _class.parseTopLevel (/opt/build/repo/node_modules/@babel/parser/lib/index.js:7470:10)
8:40:25 PM:     at _class.parse (/opt/build/repo/node_modules/@babel/parser/lib/index.js:8915:17)
8:40:25 PM:     at parse (/opt/build/repo/node_modules/@babel/parser/lib/index.js:10946:38)
8:40:25 PM:     at parser (/opt/build/repo/node_modules/@babel/core/lib/transformation/normalize-file.js:170:34)
8:40:25 PM:     at normalizeFile (/opt/build/repo/node_modules/@babel/core/lib/transformation/normalize-file.js:138:11)
8:40:25 PM:     at runSync (/opt/build/repo/node_modules/@babel/core/lib/transformation/index.js:44:43)
8:40:25 PM:     at runAsync (/opt/build/repo/node_modules/@babel/core/lib/transformation/index.js:35:14)
8:40:25 PM:     at process.nextTick (/opt/build/repo/node_modules/@babel/core/lib/transform.js:34:34)
8:40:25 PM:  @ ./assets/images/tecnospeed.svg?vue&type=script&lang=js& 1:0-210 1:226-229 1:231-438 1:231-438
8:40:25 PM:  @ ./assets/images/tecnospeed.svg
8:40:25 PM:  @ ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./components/common/navbar.vue?vue&type=script&lang=js&
8:40:25 PM:  @ ./components/common/navbar.vue?vue&type=script&lang=js&
8:40:25 PM:  @ ./components/common/navbar.vue
8:40:25 PM:  @ ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./layouts/error.vue?vue&type=script&lang=js&
8:40:25 PM:  @ ./layouts/error.vue?vue&type=script&lang=js&
8:40:25 PM:  @ ./layouts/error.vue
8:40:25 PM:  @ ./.nuxt/index.js
8:40:25 PM:  @ ./.nuxt/client.js
8:40:25 PM:  @ multi ./.nuxt/client.js

Bug? vuetify is broken when tree-shaking is enabled

Hey,

I currently use Vuetify (1.5.16) in my nuxt-app. I also use vuetify-loader to only include the used components. However, after installing this module my whole app looks like crap. The console is full of these messages:
[Vue warn]: Unknown custom element: did you register the component correctly?
It seems like the vuetify-loader rules getting overwritten or something like that.

Vuetify is implemented as a plugin, as this was the standard way before the nuxt/vuetify module.
I therefore quickly created a fresh/new nuxt-app with the nuxt-vuetify-module. After enabling tree-shaking (a must, to use vuetify-loader under the hood), the app breaks as well. See attached screenshot. Without tree-shaking, everything is fine.
BTW: the beautiful red icon is a svg with css styling -> your module works :)

I don't know, if this should be fixed on your side or vuetify-loader? Any ideas?

Bildschirmfoto 2019-08-07 um 23 36 15

Only run inside script tag

Is it possible to apply the loader on for SVG loaded inside <script> tags ?
This would remove the need to use ?inline inside <style> tag.
Seem like it would be possible with source.vue?vue&type=script

Class prefix breaks TailwindCSS utility classes

Hi Alex and Nuxt/Tailwind folks

Cheers for the awesome module! I'm super stoked to use it, but I can't get it working with TailwindCSS.

Usually, I put my SVG in a Vue component. I give the SVG class="w-full h-auto" and fill="currentColor", then I control the size and color with the parent element.

I hoped to do the same with this module, but I can't get the responsive/flexible sizing configured. Inspecting the dev tools, I can see that the class names are being prefixed with BaseLogo_svg__w-full BaseLogo_svg__h-auto ..I guess this is the problem. Is there a way to turn these prefixes off?

If not, could you give any tips on how to style them responsively using TailwindCSS?

Chrome dev tools
Screen Shot 2021-04-30 at 13 39 19

BaseLogo.svg
Screen Shot 2021-04-30 at 13 42 00

TheFooter.vue
Screen Shot 2021-04-30 at 13 38 27

nuxt.config.js

   [
      'nuxt-svg-loader',
      {
        svgoConfig: {
          plugins: [
            { prefixIds: false }, // I thought this might disable it, but I can't see a change true or false
          ],
        },
      },
    ],

Many thanks,
Mel

Vetur complains about module

When I use this with Vetur it'll complain about not finding a module at my import ... path. Is there a way to fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.