Cwd in Grunt + Babel

Asked

Viewed 27 times

0

Personal talk, I am using Grunt + Babel to compile my code, it turns out that my folders are organized as follows:

- pasta1
    - amd
        -src 
            - arquivo.js
- pasta2
     - amd
         -src 
            - arquivo.js
- pasta3
  -subpasta3
      - amd 
         - src
            -arquivo.js

And I can only use Abel in a very specific way, for example:

grunt.initConfig({
    babel: {
      options: {
        sourceMap: false,
        presets: ['env']
      },
      dist: {
        files: [{
          expand: true,
          cwd: './pasta1/amd/src', // aqui so especifico a pasta1
          src: ['*.js'],
          dest: '.pasta1/amd/babel/' // aqui so especifico a pasta1
        }]
      }
    }

I wanted it to run in all amd/src folders and generate inside the amd folder itself/ the files compiled by Babel, I’ve tried the following:

grunt.initConfig({
    babel: {
      options: {
        sourceMap: false,
        presets: ['env']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '**/amd/src',  
          src: ['*.js'],
          dest: '**/amd/babel/' 
        }]
      }
    }

CWD: I don’t know why it doesn’t work, the idea was to take all the folders that contain the amd/src folders and make it the basis

DEST: in that part I have no idea how to leave the dest (Babel/ generated folder) exactly inside the folder that src is in, for example... inside paste1/src create the Babel/ folder with all files . js compiled from pasture 1, within pasture2/src create folder Babel/ with tds files. js compiled from pasture2

  • Renan, the second idea - that is, put the code generated by Babel within a sub-folder of the src that you’re sweating probably isn’t a good idea. Transpilate to a folder lib or dist will save you a lot of headache with Babel and other Build tools.

  • Doesn’t work by adding . / ? Ex: cwd: './/amd/src' and dest: './/amd/Babel/'

  • So Anthony, I wrote wrong kk, I have several plugins (several folders) and each folder contains the amd/ and src/ folders... I wanted each amd/ folder (which is in several other plugins folders) to generate the Babel build... getting more or less like this amd/ -> src/ and build/

  • Gleidson, I’ve tried it like this :/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.