简体   繁体   中英

Convert .css to .min.css

This is the sample gruntfile.js where the cssmin which is supposed ot minify .css to .min.css is not working.

module.exports = function (grunt) {
    var buildDir = "build";

    grunt.initConfig({
        clean: {

        },
        cssmin: {
            minify: {                
                expand: true,
                cwd: "somePath/dataTables/css/",
                src: ['*.css'],
                dest: "somePath/dataTables/css/",
                ext: '.min.css'
            }
        },
        requirejs: {
            compile: {
                options: {
                }
            },
        },
    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.registerTask('build', ['clean:build', 'cssmin', 'requirejs']);
    grunt.registerTask('test', ['jshint', 'karma:default']);
}

I had added a reference in package.json as well.

  1. any reason why this mincss is not working.
  2. how ot add debug / log to see if mincss is getting executed.

I'm doing it that way and all the files are perfectly minified.

module.exports = function(grunt) {
  'use strict';

  grunt.initConfig({
    uglify  : {
      production : {
        src     : ['**/*.js', '**/*.*.js', '**/*.*.*.js', '**/*.*.*.*.js', '!*.min.js'],
        cwd     : 'development/js/',
        dest    : 'production/js/',
        expand  : true,
        ext     : '.main.min.js',
      },
    },
    cssmin : {
      minify : {
        expand: true,
        cwd   : 'development/css/',
        src   : ['*.css', '!*.min.css'],
        dest  : 'production/css/',
        ext   : '.min.css'
      }
    }
  });


  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.registerTask('default', ['uglify', 'cssmin']);
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM