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

前端 未结 5 689
借酒劲吻你
借酒劲吻你 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:00

    Not exactly an answer to your question but i made it here looking for relative dest folders with grunt so... Here is how i solved it

    ...
    base: {
      files:
      [
        {
          expand: true,
          cwd: 'app/design/frontend/',
          src: ['**/Magento_Sales/email-src/*.html'],
          dest: '../../Magento_Sales/email/',
          rename: function(dest, src, expand) {
            src = path.parse(src)
            return path.join(expand.cwd, src.dir, dest, src.base);
          }
        },
      ],
    }
    ...
    

    This little bit path.join(expand.cwd, src.dir, dest, src.base); just creating the path i need.

    expand.cwd = app/design/frontend/

    src.dir = /Magento_Sales/email-src/

    dest = ../../Magento_Sales/email/

    src.base = .html

    and all together it = app/design/frontend///Magento_Sales/email/.html

    and in my situation it will now compile my html emails in relative destination folders

提交回复
热议问题