Search code examples
javascriptgruntjsgrunt-contrib-concat

How can I run concat for cases without any scripts?


As a part of my Gruntfile.js:

...

concat: {

    ...

    js: {
        src: [
            'src/**/*.js'
        ],
        dest: 'build/js/main.js',
        nonull: true
    }
},

...

How can I prevent concat from generating a blank main.js if my src directory contains no scripts? Must I really create a separate task if I know I won't need to build any scripts?


Solution

  • Not exactly a proper solution, but I managed to find a package called grunt-cleanempty which I set to run after concat to delete any generated empty files.