S
S
Sergey Shilov2016-04-13 17:27:04
Node.js
Sergey Shilov, 2016-04-13 17:27:04

When you start watch, it says waiting for a long time after the grunt command, what's the matter?

Good afternoon, I'm new to grunt. When I execute the grunt command, the process hangs for a long time:

Running "concat:dist" (concat) task

Running "uglify:build" (uglify) task
File assets/js/production.min.js created: 69.55 kB → 60.28 kB
>> 1 file created.

Running "watch" task
Waiting...

Here is the gruntfile.js file:
module.exports = function(grunt) {

    // 1. Вся настройка находится здесь
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        concat: {
            dist: {
                src: [
                    'assets/js/libs/*.js',
                    'assets/js/vendor/*.js',
                    'assets/js/parts/*.js'
                ],
                dest: 'assets/js/production.js'
            }
        },
        uglify: {
            build: {
                src: 'assets/js/production.js',
                dest: 'assets/js/production.min.js'
            }
        },
        watch: {
            scripts: {
                files: [
                    'assets/js/*.js',
                    'assets/css/production.css'
                ],
                tasks: ['concat', 'uglify'],
                options: {
                    spawn: false
                },
            }
        },
        imagemin: {
            dynamic: {
                files: [{
                    expand: true,
                    cwd: 'assets/images/',
                    src: ['**/*.{png,jpg,gif}'],
                    dest: 'assets/images/build/'
                }]
            }
        },
        less: {
            development: {
                options: {
                    paths: ["assets/css"],
                    compress: true
                },
                files: {
                    "assets/css/production.css": "assets/css/production.less"
                }
            }
        },
        autoprefixer: {
            options: {
                browsers: ['last 2 versions', 'ie 9']
            },
            your_target: {
                src: 'assets/css/production.css',
                dest: 'assets/css/production.css'
            }
        }
    });

    // 3. Тут мы указываем Grunt, что хотим использовать этот плагин
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-imagemin');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-autoprefixer');
    
    // 4. Указываем, какие задачи выполняются, когда мы вводим «grunt» в терминале
    grunt.registerTask('default', ['concat', 'uglify', 'watch', 'imagemin', 'less', 'autoprefixer']);
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Bogachev, 2016-04-13
@Olivoin

watch waits for file changes

files: [
    'assets/js/*.js',
    'assets/css/production.css'
],

in order to perform tasks when they change,
this is often used to rebuild the project "in real time" and see the result

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question