grunt 检测js配置

module.exports = function(grunt) {

    // 项目配置
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
            },
            build: {
                files: [{
                    expand: true, //启用动态扩展
                    cwd: 'src/', //批匹配相对lib目录的src来源
                    src: '**/*.js', //实际的匹配模式
                    dest: 'build/', //目标路径前缀
                    ext: '.min.js' //目标文件路径中文件的扩展名.
                }]
            }
        },
        jshint: {
            // define the files to lint
            files: ['gruntfile.js', 'src/**/*.js'],
            // configure JSHint (documented at http://www.jshint.com/docs/)
            options: {
                // more options here if you want to override JSHint defaults
                globals: {
                    jQuery: true,
                    console: true,
                    module: true
                }
            }
        }

    });

    // 加载提供"uglify"任务的插件
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');

    // 默认任务
    grunt.registerTask('default', ['uglify']);
    grunt.registerTask('jiance', ['jshint']);
};
posted @ 2014-03-29 20:40  互联网Fans  阅读(234)  评论(0编辑  收藏  举报