0

concat grabs all the htm pages and puts them into 1 which is /templates/min/production.htm

What I am trying to achieve is /templates/min/production.min.htm, I get no errors in terminal window.

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 your way

@mario this is running the code your way, and it seems to not find the source file... but I think it's supposed to be destination: source... not source: destination.. I'm going to post the response I get when doing destination: source too

@mario my way ie my code posted above

This is the response I'm getting in my terminal window while running the code as I posted above.

changing it to destination: source

@mario it seems to be freezing on reading the production.htm.

grunt version

Is it anything to do with my grunt version? Must I have version 4.0? I have 4.5, should it still work? Also there are many other errors, any of them ring any bells into why my html is not minifying?

halfer
  • 19,824
  • 17
  • 99
  • 186
Dally S
  • 619
  • 9
  • 11

1 Answers1

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.

Mario Araque
  • 4,562
  • 3
  • 15
  • 25
  • cheers for the reply... but have already given that a try and didn't work :( and did just try again, and still not minifying my html – Dally S Oct 01 '14 at 16:20
  • What happen if you type _grunt htmlmin -v_ in your console? – Mario Araque Oct 01 '14 at 16:21
  • 1
    and i think its files{ destination: source } not files{source: destination} – Dally S Oct 01 '14 at 16:22
  • shall i try it with my original code or code recommended by you? and can you confirm whether its source: destination or destination source? as when i try destion: source it freezes on running htmlmin.. – Dally S Oct 01 '14 at 16:27
  • Both if you want please. My code is based in documentation, but yours maybe works too. – Mario Araque Oct 01 '14 at 16:27