How can I rename files with Grunt, based on the respective file's parent folder name?

前端 未结 5 686
借酒劲吻你
借酒劲吻你 2021-01-30 10:28

I have a the following structure:

src/
    modules/
        module1/
            js/
                main.js
            scss/
                main.scss
                 


        
5条回答
  •  既然无缘
    2021-01-30 11:15

    if u want to rename .coffee files to .js or similar then just adapt it ;)

    sudo npm install grunt-contrib-copy

    copy: {
      rename: {
        files: [{
         expand: true,
         dot: true,
         cwd: './app/scripts',
         dest: './app/scripts/',
         src: [
           '**/*.coffee'
         ],
         rename: function(dest, src) {
           console.log(dest + src);
           return dest + src.replace('.coffee','.js');
         }
       }]
      }
    },
    

提交回复
热议问题