Grunt/Assembly-输出html缩小

Grunt/Assembly-输出html缩小,html,gruntjs,handlebars.js,minify,assemble,Html,Gruntjs,Handlebars.js,Minify,Assemble,我正在使用Grunt和assemble为静态站点构建HTML页面,我想缩小HTML 因此,我假设组装插件,根据数据集运行车把模板,将有一个缩小选项 组装文件上没有提到这一点; 但有一个提到,暗指在车把助手缩小文档; -但这没有效果 我在互联网上找不到其他任何东西,当然这是一个更常见的请求 grunt.initConfig({ assemble: { options: { assets: '../source',

我正在使用Grunt和assemble为静态站点构建HTML页面,我想缩小HTML

因此,我假设组装插件,根据数据集运行车把模板,将有一个缩小选项

组装文件上没有提到这一点;

但有一个提到,暗指在车把助手缩小文档; -但这没有效果

我在互联网上找不到其他任何东西,当然这是一个更常见的请求

grunt.initConfig({
    assemble: {
                options: {
                    assets: '../source',
                    data: ['package.json','data/*.{json,yml}'],
                    partials: 'templates/modules/*.hbs',
                    ext: '.html',
                    helpers: 'templates/helpers/*.js',
                    layout: 'templates/layout/master.hbs',
                    removeHbsWhitespace: true,
                    minify: {
                        removeAttributeQuotes: true,
                        collapseWhitespace: true
                    }
                },
                dev: {
                    options: {
                        production: false
                    },
                    files: [{
                        expand: true,
                        cwd: 'templates/pages',
                        src: ['*.hbs'],
                        dest: '../source'
                    }]
                }
    }
});
请由Assembly的作者之一签出。除项目自述文件外,该文件的使用示例如下:

/**
 * Beautify generated HTML to make diffs easier
 */
prettify: {
    tests: {
        options: {ocd: true},
        files: [
            {expand: true, cwd: 'test/actual', src: ['**/*.html'], dest: 'test/actual/', ext: '.html'}
        ]
    }
},
祝你好运

请查看《汇编》的作者之一。除项目自述文件外,该文件的使用示例如下:

/**
 * Beautify generated HTML to make diffs easier
 */
prettify: {
    tests: {
        options: {ocd: true},
        files: [
            {expand: true, cwd: 'test/actual', src: ['**/*.html'], dest: 'test/actual/', ext: '.html'}
        ]
    }
},

祝您好运

您需要在Gruntfile中显式注册{{minify}}helper

helpers: ['handlebars-helper-minify', 'templates/helpers/*.js']
或者,尝试将Handlebar helper minify模块添加到项目的package.json中的devdependency和关键字中

在master.hbs布局中,用{{minify}将其包装起来,例如:

{{#minify}}
  {{> header }}
  {{> body }}
  {{> footer }}
{{/minify}}

您需要在GrunFile中显式注册{{minify}}helper

helpers: ['handlebars-helper-minify', 'templates/helpers/*.js']
或者,尝试将Handlebar helper minify模块添加到项目的package.json中的devdependency和关键字中

在master.hbs布局中,用{{minify}将其包装起来,例如:

{{#minify}}
  {{> header }}
  {{> body }}
  {{> footer }}
{{/minify}}