Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify html template #385

Closed
rbao opened this issue Mar 4, 2016 · 4 comments
Closed

Minify html template #385

rbao opened this issue Mar 4, 2016 · 4 comments

Comments

@rbao
Copy link

rbao commented Mar 4, 2016

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

@prayagmk
Copy link

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

@valorkin
Copy link
Contributor

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

@PatrickJS
Copy link
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

@prayagmk
Copy link

@gdi2290 @valorkin Thanks. It worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants