search

Home  >  Q&A  >  body text

node.js - babel directive how to skip translation of certain files?

How can the babel command skip the translation of certain files?
Currently using:

babel src -s -D -d dist

.babelrc

{
  "presets": [
    "es2015",
    "stage-2"
  ],
  "plugins": [
      ["transform-runtime", {
        "polyfill": false,
        "regenerator": true
      }]
  ]
}

All files in src will be translated and saved to dist
Now you need to save the src/app files directly to dist without translation, while other files in src will still be translated.
Thanks! ! !

仅有的幸福仅有的幸福2750 days ago815

reply all(2)I'll reply

  • PHPz

    PHPz2017-05-16 13:40:31

    I have a question, why don’t you take a look babel --help

    Option Default Description
    -i, --ignore [regex] node_modules Ignore all files that match this regex when using the require hook
    babel src -s -D -d dist --ignore src/app

    reply
    0
  • 迷茫

    迷茫2017-05-16 13:40:31

    You can use --ignore或者--copy-fileparameters:

    babel src -s -d dist --ignore src/app/*.js

    --copy-fileI haven’t used it specifically, you can refer to
    How to use the CLI tools

    reply
    0
  • Cancelreply