相关疑难解决方法(0)

如何创建和组织配置和注册grunt任务

我有一个项目,我grunt用来处理我JsSASS文件.

目前,当我需要处理某些内容时,gruntfile.js即使我只想更改一个模块或仅更改SASS文件,我也需要调用我内部的所有任务.

有没有办法创建自定义任务,只运行sass部分,另一个只创建模块进程,我可以从提示中调用此任务?

这是我尝试过的,没有成功:

    module.exports = function(gruntHome) {

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

        /* @CONCAT */
        concat: {
            home : {
                src: 'src/app/component/home/*.js',
                dest: 'src/app/component/home/concat/concat_config.js'
            }
        },

        /* @ANNOTATE */
        ngAnnotate: {
            options: {
                add: true
            },
            home: {
                files: {
                    'src/app/component/home/concat/concat_config.js': 'src/app/component/home/concat/concat_config.js'
                }
            }
        },

        /* @UGLIFY */
        uglify: {
            home: {
                src:  'src/app/component/home/concat/concat_config.js',
                dest: 'app/component/home/home.min.js'
            }
        }
    });


    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-ng-annotate');

    grunt.registerTask('gruntTask', ['concat', 'ngAnnotate', 'uglify']);
};
Run Code Online (Sandbox Code Playgroud)

如果不可能,还有其他方法可以实现这一目标吗?因为我的gruntfile.js很大,有时需要花费很多时间来处理,即使我不需要处理所有内容.


编辑:

这里的链接 …

javascript node.js gruntjs

3
推荐指数
1
解决办法
866
查看次数

标签 统计

gruntjs ×1

javascript ×1

node.js ×1