Gruntjs grunt htmlmin-无法缩小htm请帮助,完美缩小css和js

Gruntjs grunt htmlmin-无法缩小htm请帮助,完美缩小css和js,gruntjs,grunt-contrib-htmlmin,Gruntjs,Grunt Contrib Htmlmin,concat获取所有htm页面并将它们放入1,即/templates/min/production.htm 我试图实现的是/templates/min/production.min.htm,在终端窗口中没有错误。。。如果你们想进一步了解,请告诉我 module.exports = function (grunt) { // 1. All configuration goes here grunt.initConfig({ pkg: grunt.file.read

concat获取所有htm页面并将它们放入1,即/templates/min/production.htm

我试图实现的是/templates/min/production.min.htm,在终端窗口中没有错误。。。如果你们想进一步了解,请告诉我

module.exports = function (grunt) {

    // 1. All configuration goes here
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            controlCss: {
                src: ['UI.controls/assets/css/*.css'],
                dest: 'UI.controls/assets/css/min/production.css'
            },

            controlJs: {
                src: ['UI.controls/assets/js/*.js'],
                dest: 'UI.controls/assets/js/min/production.js'
            },

            coreJs: {
                src: ['UI.core/assets/js/*.js'],
                dest: 'UI.core/assets/js/min/production.js'
            }

            ,
            controlHtml: {
                src: ['UI.controls/assets/templates/*.htm'],
                dest: 'UI.controls/assets/templates/min/production.htm'
            }
        },

        cssmin: {
            controlCss: {
                src: 'UI.controls/assets/css/min/production.css',
                dest: 'UI.controls/assets/css/min/production.min.css'
            }
        },

        uglify: {
            controlJs: {
                src: 'UI.controls/assets/js/min/production.js',
                dest: 'UI.controls/assets/js/min/production.min.js'
            },

            coreJs: {
                src: 'UI.core/assets/js/min/production.js',
                dest: 'UI.core/assets/js/min/production.min.js'
            }
        },


        htmlmin: {
            controlHtml: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true
                },
                expand: true,
                cwd: 'expand',
                src: 'UI.controls/assets/templates/min/production.htm',
                dest: 'UI.controls/assets/templates/min/production.min.htm'
            }
        }



    });

    // 2. Where we tell Grunt we plan to use this plug-in.
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');

    // 3. Where we tell Grunt what to do when we type "grunt" into the terminal.
    grunt.registerTask('default', ['concat', 'cssmin', 'uglify', 'htmlmin']);

};

@马里奥这是你的方式运行的代码,它似乎没有找到源文件。。。但我认为它应该是目的地:来源。。。不是源:目标。。我将发布我在执行destination:source时得到的响应

这是我在运行@mario上面发布的代码时在终端窗口中得到的响应

]

@马里奥:看《制作》的时候,它似乎冻结了。htm:(感谢你的帮助

这和我的grunt版本有关吗?我必须有4.0版吗?我有4.5版..它还能用吗? 还有许多其他错误…其中任何错误都会提醒我为什么我的html没有缩小?感谢您的帮助。提前感谢您根据,您必须这样编写任务:

    htmlmin: {
        controlHtml: {
            options: {
                removeComments: true,
                collapseWhitespace: true
            },
            files: {
                 'UI.controls/assets/templates/min/production.htm': 'UI.controls/assets/templates/min/production.min.htm'
            }
        }
    }
希望能有帮助


问候。

htmlmin部分似乎没有做任何事情为回复干杯……但已经尝试了一下,但没有成功:(只是再试一次,仍然没有缩小我的HTMLM如果你在控制台中键入grunt htmlmin-v会发生什么?我想它的文件{destination:source}不是文件{source destination}我应该用我的原始代码还是你推荐的代码来试试吗?你能确认它的源代码是:destination还是destination source吗?当我尝试destinon:source时,它会在运行htmlmin时冻结。如果你愿意的话,两者都可以。我的代码是基于文档的,但你的可能也可以。