gruntjs - Write file even if output css is empty -


i want write empty file destination file empty.

is possible?

the error "destination not written because minified css empty".

i'm using grunt-contrib-cssmin module.

only using grunt-contrib-cssmin, cannot.

a place start when wondering specific piece of open source software: source code — task ~70 lines. the source can see "error" you're getting:

if (min.length === 0) {     return grunt.log.warn('destination not written because minified css empty.'); } 

you might want "touching" file. if familiar *nix, you'll know touch create file if doesn't exist , not truncate if does. in grunt (node.js) might want node-touch or grunt-exec.

as gruntfile, you'd need one of following 2 tasks:

module.exports = function (grunt) {     var touch = require('touch');     grunt.initconfig({         'cssmin': {             'combine': {                 'files': { 'path/to/output.css': ['path/to/input_one.css', 'path/to/input_two.css'] }             }         },         'exec': {             'touch': { 'command': 'touch path/to/output.css' }         }     });     grunt.loadnpmtasks('grunt-contrib-cssmin');     grunt.loadnpmtasks('grunt-exec');     grunt.registertask('touch', touch.sync.bind(undefined, 'path/to/output.css'));     grunt.registertask('minifycss1', ['cssmin', 'exec:touch']); // 1     grunt.registertask('minifycss2', ['cssmin', 'touch']);      // 2 }; 
  1. uses grunt-exec.
  2. uses node-touch.

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -