Grunt: How to build the files object dynamically

前端 未结 2 1912
陌清茗
陌清茗 2021-01-23 06:25

I must be missing something very simple here. I\'m trying to write a function task that deals with files. The Grunt API docs mention that you can [Build the files object dynamic

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-23 07:04

    You can use rename function to change file name is files object like below...

    build: {
      files: [{
        expand: true,
        cwd: 'src',
        src: ['**/*.js'],
        dest: 'dist',
        rename: function(dest, src) {
          /* 
             rename logic
             you will have access to src and dest name and can return desirect name from this function.
          */
          return src+123;
        }
     }]
    }
    

提交回复
热议问题