Grunt Watch - 验证财产

时间:2014-05-29 15:54:44

标签: gruntjs watch

我正在尝试分离我的grunt文件,以便我可以处理两个单独的代码块,所有内容似乎都与监视任务分开。

我收到以下错误,它会循环直到超出调用堆栈

Waiting...Verifying property watch.app.files exists in config...ERROR
>> Unable to process task.
Warning: Required config property "watch.app.files" missing.

似乎它不喜欢我的手表任务被分成两部分。我环顾四周,这对其他人来说似乎不是一个问题。

我的gruntfile看起来像这样:

module.exports = function(grunt) {

    // 1. All configuration goes here
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        concat: {
            app: {
                src: [
                    'themes/site_themes/app/scripts/build/libs/!(html5shiv|respond).js',
                    'themes/site_themes/app/scripts/build/modules/*.js'
                ],
                dest: 'themes/site_themes/app/scripts/production/app.min.js'
            },
            marketing: {
                src: [
                    'themes/site_themes/marketing/scripts/build/libs/!(html5shiv|respond).js',
                    'themes/site_themes/marketing/scripts/build/modules/*.js'
                ],
                dest: 'themes/site_themes/marketing/scripts/production/app.min.js'
            }
        },
        uglify: {
            app: {
                files: {
                    'themes/site_themes/app/scripts/production/app.min.js': ['themes/site_themes/app/scripts/production/app.min.js'],
                    'themes/site_themes/app/scripts/production/html5shiv.min.js': ['themes/site_themes/app/scripts/build/libs/html5shiv.js'],
                    'themes/site_themes/app/scripts/production/respond.min.js': ['themes/site_themes/app/scripts/build/libs/respond.js'],
                }
            },
            marketing: {
                files: {
                    'themes/site_themes/marketing/scripts/production/app.min.js': ['themes/site_themes/marketing/scripts/production/app.min.js'],
                    'themes/site_themes/marketing/scripts/production/html5shiv.min.js': ['themes/site_themes/marketing/scripts/build/libs/html5shiv.js'],
                    'themes/site_themes/marketing/scripts/production/respond.min.js': ['themes/site_themes/marketing/scripts/build/libs/respond.js'],
                }
            }
        },
        jshint: {
            app: {
                all: ['themes/site_themes/app/scripts/build/modules/!(analytics).js', 'themes/site_themes/app/scripts/build/app.js'],
            },
            marketing: {
                all: ['themes/site_themes/marketing/scripts/build/modules/!(analytics).js', 'themes/site_themes/marketing/scripts/build/app.js'],
            }
        },
        sass: {
            app: {
                options: {
                    style: 'compressed'
                },
                files: {
                    'themes/site_themes/app/styles/production/style.min.css':'themes/site_themes/app/styles/build/style.scss'
                }
            },
            marketing: {
                options: {
                    style: 'compressed'
                },
                files: {
                    'themes/site_themes/marketing/styles/production/style.min.css':'themes/site_themes/marketing/styles/build/style.scss'
                }
            }
        },
        autoprefixer: {
            options: {
                browsers: ['last 2 versions', 'ie >= 8']
            },
            app: {
                no_dest: {
                    src: 'themes/site_themes/app/styles/production/style.min.css',
                }
            },
            marketing: {
                no_dest: {
                    src: 'themes/site_themes/marketing/styles/production/style.min.css',
                }
            }
        },
        watch: {
            app: {
                jshint: {
                    files: ['themes/site_themes/app/scripts/build/modules/!(analytics).js', 'themes/site_themes/app/scripts/build/app.js'],
                    tasks: 'jshint:app'
                },
                scripts: {
                    files: ['themes/site_themes/app/scripts/build/*/*.js'],
                    tasks: ['concat:app', 'uglify:app'],
                    options: {
                        spawn: false,
                    },
                },
                css: {
                    files: ['themes/site_themes/app/styles/build/*.scss', 'themes/site_themes/app/styles/build/inuit/*/*.scss', 'themes/site_themes/app/styles/build/theme/*/*.scss'],
                    tasks: ['sass:app', 'autoprefixer:app'],
                    options: {
                        livereload: true,
                        spawn: false,
                    }
                }
            },
            marketing: {
                jshint: {
                    files: ['themes/site_themes/marketing/scripts/build/modules/!(analytics).js', 'themes/site_themes/marketing/scripts/build/app.js'],
                    tasks: 'jshint:marketing'
                },
                scripts: {
                    files: ['themes/site_themes/marketing/scripts/build/*/*.js'],
                    tasks: ['concat:marketing', 'uglify:marketing'],
                    options: {
                        spawn: false,
                    },
                },
                css: {
                    files: ['themes/site_themes/marketing/styles/build/*.scss', 'themes/site_themes/marketing/styles/build/inuit/*/*.scss', 'themes/site_themes/marketing/styles/build/theme/*/*.scss'],
                    tasks: ['sass:marketing', 'autoprefixer:marketing'],
                    options: {
                        livereload: true,
                        spawn: false,
                    }
                }
            }
        }


    });

    // 3. Where we tell Grunt we plan to use this plug-in.
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-autoprefixer');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');

    // 4. Where we tell Grunt what to do when we type "grunt" into the terminal.
    grunt.registerTask('default', ['concat:app', 'uglify:app', 'jshint:app', 'sass:app', 'autoprefixer:app', 'watch:app']);
    grunt.registerTask('marketing', ['concat:marketing', 'uglify:marketing', 'jshint:marketing', 'sass:marketing', 'autoprefixer:marketing', 'watch:marketing']);

};

1 个答案:

答案 0 :(得分:1)

刚刚找到this。看起来监视不支持嵌套目标。

如果我这样做的话,我会尝试找到另一种方法来发布。