svg-module icon indicating copy to clipboard operation
svg-module copied to clipboard

Inline SVGs with no styles when build/generate

Open mickaelchanrion opened this issue 4 years ago ā€¢ 3 comments

Hi! When using vue-svg-loader (?inline), if the svg file contains <style> in the defs, then it will apparently be ignored and the svg will be with no style once the Nuxt app is built/generated.

Issue #24 was about that problem and it is now closed, yet I think no effective solution has been provided so far. So ok, we can use the raw-loader but still, the original problem remains hence a new issue.

In a project, I ended up fixing that issue by replacing the loader by svg-to-vue-component:

function setup(config, options = {}) {
  // ...
  const rule = {
    test: /\.svg$/i,
    oneOf: [
      {
        resourceQuery: /inline/,
        use: [
          'vue-loader',
          {
            loader: 'svg-to-vue-component/loader',
            options: options.inline,
          }
        ],
  // ...

It seems to be working well. Should I open a PR?

mickaelchanrion avatar Oct 14 '20 10:10 mickaelchanrion

I'll happily accept a PR! Please could it use a resourceQuery of /component/? Thank you šŸ˜„

sam3d avatar Oct 14 '20 11:10 sam3d

Ok so I keep the inline one?

mickaelchanrion avatar Oct 14 '20 11:10 mickaelchanrion

Yes please. Iā€™d like to avoid breaking changes if possible.

On 14 Oct 2020, at 12:26, Mickael Chanrion [email protected] wrote:

Ok so I keep the inline one?

ā€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nuxt-community/svg-module/issues/61#issuecomment-708339934, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB77H6F66BKXBMKVEJDG35DSKWDFFANCNFSM4SQOF5AA.

sam3d avatar Oct 14 '20 12:10 sam3d