0

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']);

};

@mario 你的方式

@mario这是按照你的方式运行代码,它似乎找不到源文件......但我认为它应该是目的地:来源......而不是来源:目的地......我将发布回复get when doing destination: source too

@mario 我的方式,即我在上面发布的代码

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

![将其更改为目的地:来源] 4

@mario 在阅读 production.htm 时似乎很冷 :( 感谢您的帮助

咕噜版本

这和我的咕噜版本有什么关系吗?我必须有 4.0 版吗?我有 4.5 .. 它还可以工作吗?还有许多其他错误...它们中的任何一个都响起为什么我的html没有缩小?感谢任何帮助。提前致谢

4

1 回答 1

0

According to htmlmin documentation, you have to write the task like this:

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

Hope it helps.

Regards.

于 2014-10-01T16:09:59.303 回答