Programmatically pass arguments to grunt task?

前端 未结 2 1109
暗喜
暗喜 2020-12-02 20:19

I have a grunt task that calls other grunt tasks. I want to call a subtask with programmatically determined arguments. Is this possible? I spent some time digging around the

相关标签:
2条回答
  • 2020-12-02 20:41

    I figured it out. Use the <%= %> syntax in Gruntfile.js:

    compass: {
      default_options: {
        src: 'components/<%= myTask.src %>',
        dest: 'build',
        require: ['zurb-foundation']
      }
    }
    

    Then you can set it in your task:

    grunt.config.set('myTask.src', getSrc());
    
    0 讨论(0)
  • 2020-12-02 20:47

    You can edit all the Grunt config:

    grunt.config('compass.default_options.src', 'blabla');
    

    Just before run the task. But your solution is "cleaner".

    0 讨论(0)
提交回复
热议问题