grunt-angular-templates icon indicating copy to clipboard operation
grunt-angular-templates copied to clipboard

svg compatibility

Open MichaelRFairhurst opened this issue 11 years ago • 6 comments

When trying to use htmlmin with an svg, even with all minification settings turned off

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.0.0, 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="Your_Icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 612 792" enable-background="new 0 0 612 792" xml:space="preserve">
 ....

was turned into

<!--?xml version="1.0" encoding="utf8"?-->
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="Your_Icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 612 792" enable-background="new 0 0 612 792" xml:space="preserve">

Would be nice if (and maybe there is already a workaround for this?) it could detect svgs based on the xml declaration and/or the doctype tag, and either not minify at all or minify with different settings.

MichaelRFairhurst avatar Oct 01 '14 19:10 MichaelRFairhurst

@MichaelRFairhurst Is that related to this grunt task? Seems like an issue for htmlmin instead.

joshuacc avatar Oct 01 '14 19:10 joshuacc

Its probably more related to htmlmin...but in some ways, the bug is that its sent into htmlmin in the first place, instead of svgmin or something. I don't think the htmlmin plugin usually has any reason to face off against an svg, and the fact that an svg was sent in at all could be considered the bug. Is there a workaround to accomplish this?

MichaelRFairhurst avatar Oct 01 '14 20:10 MichaelRFairhurst

@MichaelRFairhurst What does your grunt config look like? You can exclude SVGs there.

joshuacc avatar Oct 01 '14 20:10 joshuacc

    ngtemplates: {
        app: {
            src: ['public/angular/**/*.html', 'public/svg/**/*.svg'],
            dest: 'public/templates.js',
            options: {
                prefix: '/',
                module: 'pAngularApp',
                htmlmin: {
                    collapseBooleanAttributes:      false, // SVG

compatibility collapseWhitespace: false, removeAttributeQuotes: false, // SVG compatibility removeComments: false, // Only if you don't use comment directives! removeEmptyAttributes: false, removeRedundantAttributes: false, removeScriptTypeAttributes: false, removeStyleLinkTypeAttributes: false } } } }

This is the configuration that doesn't work. I have to comment out the htmlmin property directly. And to clarify, I definitely want my svgs precached, we very commonly do ng-includes with svgs.

On Wed, Oct 1, 2014 at 1:39 PM, Joshua Clanton [email protected] wrote:

@MichaelRFairhurst https://github.com/MichaelRFairhurst What does your grunt config look like? You can exclude SVGs there.

— Reply to this email directly or view it on GitHub https://github.com/ericclemmons/grunt-angular-templates/issues/107#issuecomment-57534648 .

MichaelRFairhurst avatar Oct 01 '14 20:10 MichaelRFairhurst

@MichaelRFairhurst Could you create two subtasks for ngtemplates?

One for HTML that includes htmlmin config, and a second for svg that excludes htmlmin. Then concat the two JS files.

May not be the ideal solution, but it should work.

joshuacc avatar Oct 01 '14 21:10 joshuacc

That will work just fine, thanks!

On Wed, Oct 1, 2014 at 2:10 PM, Joshua Clanton [email protected] wrote:

@MichaelRFairhurst https://github.com/MichaelRFairhurst Could you create two subtasks for ngtemplates?

One for HTML that includes htmlmin config, and a second for svg that excludes htmlmin. Then concat the two JS files.

May not be the ideal solution, but it should work.

— Reply to this email directly or view it on GitHub https://github.com/ericclemmons/grunt-angular-templates/issues/107#issuecomment-57539086 .

MichaelRFairhurst avatar Oct 01 '14 21:10 MichaelRFairhurst