-
Notifications
You must be signed in to change notification settings - Fork 169
-
Notifications
You must be signed in to change notification settings - Fork 169
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
is there any options to minify handlebars? #72
Comments
+1 |
I now use Jade |
Whitespace is upstream handlebars, nothing to do with this loader. |
Template whitespace may be omitted from either side of any mustache statement by adding a {{#each nav ~}}
<a href="{{url}}">
{{~#if test}}
{{~title}}
{{~^~}}
Empty
{{~/if~}}
</a>
{{~/each}} with this context: {
nav: [
{url: 'foo', test: true, title: 'bar'},
{url: 'bar'}
]
} results in output sans newlines and formatting whitespace: <a href="foo">bar</a><a href="bar">Empty</a> |
Hi, SimenB & Keenwon Thank you for your prompt reply and helpful suggestion. I found a html-minify plugin which can minify my .hbs code without breaking it. It is based on htmlcompressor
My grunt config is set to: grunt task:
grunt.initConfig({
htmlcompressor: {
compile: {
expand: true,
src : ['src/templates/**/*.html'],
dest : 'compressed',
options: {
type : 'html',
preserveServerScript : true,
removeQuotes : true, //Remove unneeded quotes
removeIntertagSpaces : true,
removeSurroundingSpaces: 'min',
preserve : 'custom.hbs.rule'
}
}
},
}); and custom.hbs.rule (a skipped regular expression) is
After compression, the compressed hbs code looks like this I can easily change my webpack config to load the compressed code, says,
Alought the plugin cannot support hot module replacement for webpack, it's good enough for me. |
is there any options to remove those spaces?
The text was updated successfully, but these errors were encountered: