RequireJS + AngularJS Seed 13 _Grunt-plugin

看配置文档看得头都要炸了,敢不敢再烦点。


监控文件变化,如果文件发生追加,更新或者删除的时候,执行预定义任务。 比如:

watch: {
    server: {
        files: [".nodemon"],
        options: {
            livereload: true
        }
    }
}

Mocha 的插件: 比如:

mochaTest: {
    server: {
        src: ['test/server/**/*.js']
    }
}

Karma 的插件 比如:

karma: {
    unit: {
        configFile: 'test/client/karma.conf.js'
    }
}

Protractor 的插件 比如:

protractor: { e2e: { configFile: "test/client/protractor.conf.js", keepAlive: false } }

nodemon 的插件,用来简化工作流配置。 比如:

nodemon: {
    dev: {
        script: 'app.js',
        options: {
            nodeArgs: ['--debug', '--harmony'],
            ignore: ['node_modules/**', 'client/**'],
            callback: function (nodemon) {
                fs.writeFileSync('.nodemon', 'started');
                nodemon.on('log', function (event) {
                    console.log(event.colour);
                });
                nodemon.on('restart', function () {
                    setTimeout(function () {
                        fs.writeFileSync('.nodemon', 'restarted');
                    }, 250);
                });
            }
        }
    }
}

可以同时执行多个 Grunt 任务。 比如:

concurrent: {
    tasks: ['nodemon', 'watch'],
    options: {
        logConcurrentOutput: true
    }
}

把 ENV 作为任务配置。 比如:

grunt.registerTask('test', ['env:test', 'mochaTest:server', 'karma:unit']);

美化JShint报告。 比如:

jshint: {
    options: {
        reporter: require('jshint-stylish')
    },
    target: ['file.js']
}

加载所有 grunt-* 的任务。 比如使用 yo 新建 angular 工程的时候,在 node_modules 下安装了许多模块,

"grunt-autoprefixer": "~0.4.0",
"grunt-bower-install": "~1.0.0",
"grunt-concurrent": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.3.0",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-google-cdn": "~0.2.0",
"grunt-newer": "~0.6.1",
"grunt-ngmin": "~0.0.2",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.2.0",
"grunt-usemin": "~2.0.0",

那么使用上面的将会一把全加载。而无需挨个的 loadNpmTasks。

显示 Grunt 任务执行的时间。

转载于:https://my.oschina.net/ilivebox/blog/270992

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值