0.0.7 • Published 6 years ago

nuxt-sprite-svg-inline v0.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

nuxt-sprite-svg-inline

Build status current version Downloads

Nuxt.js plugin

If you have oneSprite.svg like this:

<svg xmlns="http://www.w3.org/2000/svg">
    <symbol id="custom-id-1">
        ...
    </symbol>
    <symbol id="custom-id-2">
        ...
    </symbol>
</svg>

Then, you can display it like this:

<svg>
    <use xlink:href="#custom-id-1"></use>
</svg>

<svg>
    <use xlink:href="#custom-id-2"></use>
</svg>

Quick start

Install:

# with npm
npm install -D nuxt-sprite-svg-inline

# with yarn
yarn add nuxt-sprite-svg-inline 

Register it on your nuxt.config.js:

const path = require('path')
const spriteSvg = require('nuxt-sprite-svg-inline')

module.exports = {
    /* ... */
    build: {
        extend (config, ctx) {
            if(ctx.isServer) {
                spriteSvg.run(path.join(__dirname,  'path/to/sprite.svg'),
                    path.join(__dirname,  '.nuxt/views/app.template.html'))
            }
        }
    }
}

It will inject your oneSprite.svg at the top of body into the app.template.html after every new build.

Example

# dev test
npm run dev

# production test
npm run build

License

MIT

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago