ludohenin / gulp-inline-ng2-template

Gulp plugin to inline HTML and CSS into Angular 2 component decorators
MIT License
126 stars 26 forks source link

Remove linebreaks & indentation #7

Closed Cotspheer closed 8 years ago

Cotspheer commented 9 years ago

Hi there

First of all, thanks for your work! Your plugin is exactly the one I needed!

Unfortunately you're adding linebreaks _\n between this character **`**_ and unnecessary whitespaces , in my eyes ;), between the start and the end. Sadly this breaks my minified HTML. Finally typescripts screws it up by rewriting those breaks into "\n \uFFFF" which are interpreted in the end by the browser.

Is there a way add a flag or something which skips the beautification or to remove it? Temporary I rewrote it like this:

From

if ('html' === opts.type)  assetFiles = opts.prop + ': `\n' + assetFiles + '\n' + indentation + '`';

To

if ('html' === opts.type)  assetFiles = opts.prop + ': `' + assetFiles + '`';

And I also removed the logic for the spaces in the "indent"-function.

function indent(str) {
      var lines = [];
      str.split('\n').forEach(function (line) {
        lines.push(line);
      });
      return lines.join('\n');
    }

In my case these works. When I minify my HTML I get an one liner. When I skip my minification I get a human readable template string.

ludohenin commented 9 years ago

Do you minify your html files before inlining them ?

ludohenin commented 8 years ago

Fixed by #19