reshape / standard

a standard plugin pack with modern template language features
Other
17 stars 6 forks source link

Minify option doesn't work when a SGR contains a SVG tag #16

Closed liitfr closed 7 years ago

liitfr commented 7 years ago

Hello ! I tried to use minification option this way :

  reshape: (ctx) => {
    return htmlStandards({
      minify: true,
      webpack: ctx
    })
  },

Then created a SGR file just for testing :

extends(src='layout.sgr')
  block(name='content')
    svg(width="178px" height="297px" viewBox="0 0 178 297" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink")
        title Slice 1
        desc Created with Sketch.
        defs
        g(id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd")
            circle(id="Oval" stroke="#979797" fill="#D8D8D8" cx="45" cy="252" r="44")
            circle(id="Oval-Copy" stroke="#979797" fill="#D8D8D8" cx="133" cy="252" r="44")
            ellipse(id="Oval-2" stroke="#979797" fill="#D8D8D8" cx="89.5" cy="113" rx="29.5" ry="112")
    p Hello

I took this SVG code in reshape/minify test fixtures, just to be sure it wouldn't come from minify package.

When I try to compile :

mathias@HAL9000:~/dev-web/sandbox$ spike compile
✗ ERROR
Error
    at NormalModule.onModuleBuildFailed (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /home/mathias/.npm-global/lib/node_modules/spike/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at context.callback (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
    at tryCatchReject (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/makePromise.js:804:4)
    at Rejected.when (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/makePromise.js:625:4)
    at Pending.run (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/Scheduler.js:27:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
⚠ WARNING
Error
    at NormalModule.onModuleBuildFailed (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /home/mathias/.npm-global/lib/node_modules/spike/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at context.callback (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
    at tryCatchReject (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/makePromise.js:804:4)
    at Rejected.when (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/makePromise.js:625:4)
    at Pending.run (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/home/mathias/.npm-global/lib/node_modules/spike/node_modules/when/lib/Scheduler.js:27:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
compiled (1.123s)

If I remove SVG tag : compilation works If I set minify: false, I get following HTML output :

...
      <svg width="178px" height="297px" viewBox="0 0 178 297" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
        <title>Slice 1</title>
        <desc>Created with Sketch.</desc>
        <defs></defs>
        <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
          <circle id="Oval" stroke="#979797" fill="#D8D8D8" cx="45" cy="252" r="44"></circle>
          <circle id="Oval-Copy" stroke="#979797" fill="#D8D8D8" cx="133" cy="252" r="44"></circle>
          <ellipse id="Oval-2" stroke="#979797" fill="#D8D8D8" cx="89.5" cy="113" rx="29.5" ry="112"></ellipse>
        </g>
      </svg>
...

See you Mat

liitfr commented 7 years ago

Oups I didn't see #3 .. sorry !