Saturday, 15 April 2017

Task is running more than once

I am trying to take advantage of grunt-newer, but for some reason it looks like babel is running 3 times in a row.

How can I make it so that it only runs one time on the new files, instead of what seems to be multiple babels?

Gruntfile

module.exports = grunt => {

require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);

// Project configuration.
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    babel: {
        options: {
            sourceMap: true,
            presets: ['babel-preset-es2015'],
            compact: true
        },
        dist: {
            files: [
                {
                    expand: true,
                    src: ['js/**/*.es6'],
                    ext: '.js'
                }
            ]
        }
    },
    concat: {
        options: {
            separator: ';'
        },
        dist: {
            src: 'js/**/*.js',
            dest: 'dist/js/script.js'
        }
    },
    concurrent: {
        js: ['newer:babel', 'concat']
    },
    watch: {
        b: {
            files: ['js/**/*.es6'],
            tasks: ['concurrent:js'],
            options: {
                nospawn: true
            }
        }
    }
});

// Default task(s).
grunt.registerTask('default', ['concurrent:js', 'watch']);

};

Output

>> File "path/to/my/file.es6" changed.

Running "concurrent:js" (concurrent) task

Running "concat:dist" (concat) task

Done, without errors.


Execution Time (2017-04-15 16:05:20 UTC+2)
loading tasks  1.3s  ████████████████████████████████████████████ 93%
concat:dist    93ms  ████ 7%
Total 1.4s

Running "newer:babel" (newer) task

Running "newer:babel:dist" (newer) task

Running "babel:dist" (babel) task

Running "newer-postrun:babel:dist:1:C:\Users\path\node_modules\grunt-newer\.cache" (newer-postrun) task

Done, without errors.


Execution Time (2017-04-15 16:05:20 UTC+2)
loading tasks     1.3s  ███████████████████████ 50%
newer:babel:dist  63ms  ██ 2%
babel:dist        1.2s  █████████████████████ 47%
Total 2.5s



via Ørnulf Arntsen

No comments:

Post a Comment