Can I have multiple gruntjs files in my project for code organization?

前端 未结 3 638
小蘑菇
小蘑菇 2020-12-14 04:08

I\'m using gruntjs for my project and was wondering if it\'s possible to have multiple grunt.js files in my project? The reason I\'m asking is that my project is organized l

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 04:34

    I know this question might be old, but I want to clarify there is a way to organise your codes in a proper way.

    To prevent having multi call like this:

    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-concat');
    

    Replace them with:

    require('load-grunt-tasks')(grunt);
    

    And use:

    grunt-config-dir
    

    To run the tasks from a folder.

    To know more about it, check this out.

提交回复
热议问题