Skip to content

Minify html template #385

Closed
Closed

Description

@rbao

I being using template: require('./user/user.component.ts') in all component. However with a big app that have lots of html the bundled file becomes really large. So I am trying to minify the html by using html-loader.

...
{ test: /\.html$/,  loader: 'html-loader', exclude: [ helpers.root('src/index.html') ] }
...

And here is my config for html-loader

  htmlLoader: {
    minimize: true,
    removeAttributeQuotes: false,
    caseSensitive: true,
    customAttrSurround: [ [/#/, /(?:)/], [/\*/, /(?:)/], [/\[?\(?/, /(?:)/] ],
    customAttrAssign: [ /\)?\]?=/ ]
  }

Then I build it with

webpack --config webpack.prod.config.js --progress --profile --colors --display-error-details --display-cached --optimize-minimize

The resulting html is minified but when I serve the app, I keep getting the following errors in the browser console

RangeError: Maximum call stack size exceeded
    at Map.<anonymous> (es6-shim.js:2801)
    at Object.c [as indexDebugNode] (debug_node.ts:166)
    at e.createElement (debug_renderer.ts:43)
    at viewFactory_t0 (viewFactory_t:219)
    at viewFactory_t0 (viewFactory_t:275)
    at viewFactory_t0 (viewFactory_t:275)
    at viewFactory_t0 (viewFactory_t:275)
    at viewFactory_t0 (viewFactory_t:275)
    at viewFactory_t0 (viewFactory_t:275)
    at viewFactory_t0 (viewFactory_t:275)

This error does not happen if I don't minify it. I am wondering if anyone else have tried to minify their html, any help is appreciated. Thanks

Activity

  1. prayagmk commented on Mar 29, 2016

    @prayagmk

    Having same issue while using the minified javascript. Have anyone got a work around?

  2. valorkin commented on Mar 29, 2016

    @valorkin
    Contributor

    Disable mangling in js minify, and be careful with html minify - it could break ng2 templates

  3. PatrickJS commented on Mar 29, 2016

    @PatrickJS
    Owner

    the RangeError: Maximum call stack size exceeded error is a problem with Angular 2's JIT templates. I set mangle to false so you should be good

  4. prayagmk commented on Mar 29, 2016

    @prayagmk

    @gdi2290 @valorkin Thanks. It worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions