drdk / grunt-dr-svg-sprites

Grunt plugin to create SVG sprites with PNG fallbacks at needed sizes
113 stars 19 forks source link

Error with name in files SVG to run task #40

Closed rflmyk closed 9 years ago

rflmyk commented 9 years ago

Good morning, I do not know why there are some svg's that give the error : Fatal error: Cannot read property 'x' of null when I run task svg-sprites , someone know why ?

phloe commented 9 years ago

Did it suddenly break without any changes to files or configuration?

rflmyk commented 9 years ago

Not, see sample: I save a svg file in the Illustrator named facebook.svg and put in folder together others files ***.svg , then I run task grunt sprite-svg when return to message.

phloe commented 9 years ago

Ok - so you added a new file. What does the svg source of it look like?

rflmyk commented 9 years ago

Yes, if I add one file in folder with name any the terminal print

Running "svg-sprites:create" (svg-sprites) task Building SVG sprites... Fatal error: Cannot read property 'x' of null

phloe commented 9 years ago

Would you mind posting a little more info here - like the name and svg-source of the file. It's hard to tell much from the error message alone.

rflmyk commented 9 years ago

Yes, follow: task

        'dr-svg-sprites': {
            create : {
                options: {
                    spriteElementPath: 'assets/imgs/svg/',
                    spritePath: 'assets/imgs/sprite/sprite.svg',
                    cssPath: 'assets/css/sass/objects/_icons.scss',
                    layout: 'packed', //packed , horizontal , vertical , diagonal
                    prefix: 'icons'
                }
            }
        }, // svg-sprites  

images names: my folder images

rflmyk commented 9 years ago

sample of names that give error:

plus-faq.svg
menu-categorias-inactive.svg

The source code plus-faq.svg:


<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1"
     id="svg2" sodipodi:docname="plus-faq.svg" inkscape:version="0.48.4 r9939" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="8px" height="8px"
     viewBox="0 0 8 8" enable-background="new 0 0 8 8" xml:space="preserve">
<sodipodi:namedview  id="namedview8" inkscape:window-height="480" inkscape:window-width="640" inkscape:pageshadow="2" inkscape:pageopacity="0" pagecolor="#ffffff" bordercolor="#666666" showgrid="false" guidetolerance="10" inkscape:cy="4" gridtolerance="10" inkscape:cx="4" objecttolerance="10" inkscape:zoom="29.5" borderopacity="1" inkscape:window-maximized="0" inkscape:current-layer="svg2" inkscape:window-y="0" inkscape:window-x="0">
    </sodipodi:namedview>
<polygon id="polygon6" fill="#FFFFFF" points="5,0 3,0 3,3 0,3 0,5 3,5 3,8 5,8 5,5 8,5 8,3 5,3 "/>
</svg>
phloe commented 9 years ago

Thanks for posting info ;) I see you used packed for layout - there was an issue fairly recently that may have been triggered by this: https://github.com/drdk/grunt-dr-svg-sprites/issues/36 Reviewing it I see it also gave the error message you encountered. We didn't find the actual bug - it was difficult to reproduce - but switching to another layout seemed to help. I'm not sure if this is would work given the number of sprite items you have - but it might work?

rflmyk commented 9 years ago

Very nice! That was it, thanks for help me! Other error that me happened was

Fatal error: Inappropriately located doctype declaration

, got it solve simply replaced

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
    <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
]>

for:

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

Till more ;)

hiulit commented 9 years ago

Any news on this layout: packed issue?

phloe commented 9 years ago

Sadly - no. But I should probably close this one and make a new issue on it.

hiulit commented 9 years ago

Created a new one https://github.com/drdk/grunt-dr-svg-sprites/issues/46