components icon indicating copy to clipboard operation
components copied to clipboard

Use with webpack loaders (for SVG's as component)

Open drewbaker opened this issue 4 years ago • 2 comments

It would be great if this supported your defined custom webpack loaders, so we could use SVG's as components and have them auto imported.

I wish we could do this:

// In template
<template>
    <svg-logo/>
</template>
// nuxt.config.js
components: [
    { path: "~/components", extensions: ["vue"] },
    { path: "~/assets/svgs/", prefix: "svg", extensions: ["svg"] }
],
build: {
    extend(config, { isDev, isClient }) {
        // Add SVG loader
        config.module.rules.push({
            test: /\.svg$/,
            use: [
                "babel-loader",
                {
                    loader: "vue-svg-loader",
                    options: {
                        svgo: {
                            plugins: [{ removeViewBox: false }]
                        }
                    }
                }
            ]
        })
    }

drewbaker avatar Jul 03 '20 23:07 drewbaker

Can svgs currently be dynamically / lazy loaded through components ?

MentalGear avatar Nov 20 '20 12:11 MentalGear

@pi0 any tips how how we can or should be using this with SVGs (as Vue components with a loader?)

drewbaker avatar Apr 16 '21 22:04 drewbaker