Giter VIP home page Giter VIP logo

Comments (2)

danielstgt avatar danielstgt commented on June 5, 2024 1

tl;dr

Upgrade your Laravel Mix SVG Vue Version:

# npm
npm install laravel-mix-svg-vue@^0.4.1

# yarn
yarn add laravel-mix-svg-vue@^0.4.1

Enable removeViewBox and disable removeDimensions in the SVGO settings, e.g.:

mix.js('resources/js/app.js', 'public/js')
    .vue()
    .svgVue({
        svgoSettings: [
            { removeViewBox: true },
            { removeDimensions: false }
        ]
    });

Explanation

Older versions of this plugin only respected the viewBox attribute of the SVGO generated string. I'm actually surprised that this wasn't mentioned before, could be because viewBox is mainly prefered over the width/height attributes. Besides this plugin, SVGO also has this option enabled as default setting.

New versions of the svg-vue and svg-vue3 components have been released that include every attribute that SVGO generates as optimized version.

Based on your SVGO settings, you have to enable or disable the removeViewBox or removeDimensions to get either the viewBox or width/height attributes. That means you have to use the following settings to keep the width and height attributes:

.svgVue({
    svgoSettings: [
        { removeViewBox: true },
        { removeDimensions: false }
    ]
})

You can check the defaults of SVGO here: SVGO Bult-in plugins

I've tagged a new version of Laravel Mix SVG Vue which includes the new Vue.js components. Upgrading to laravel-mix-svg-vue@^0.4.1 should fix your issues.

Let me know if the new version produces the desired output of the svg.

from laravel-mix-svg-vue.

o1y avatar o1y commented on June 5, 2024 1

Perfect! Thanks so much for fixing this issue.

The new version produces exactly the desired output from all of my svgs. :)

from laravel-mix-svg-vue.

Related Issues (12)

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.