4d3708fb9995a58c147c131adc60b1732304b7c869927a965a336617e3e5a3f4b3196e44f38a57fa1c2b6a91eb58c041cc4380c77878f53cdbe140b3a064b1 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # @vue/cli-plugin-babel
  2. > babel plugin for vue-cli
  3. ## Configuration
  4. Uses Babel 7 + `babel-loader` + [@vue/babel-preset-app](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app) by default, but can be configured via `babel.config.js` to use any other Babel presets or plugins.
  5. By default, `babel-loader` excludes files inside `node_modules` dependencies. If you wish to explicitly transpile a dependency module, you will need to add it to the `transpileDependencies` option in `vue.config.js`:
  6. ``` js
  7. module.exports = {
  8. transpileDependencies: [
  9. // can be string or regex
  10. 'my-dep',
  11. /other-dep/
  12. ]
  13. }
  14. ```
  15. ## Caching
  16. [cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/babel-loader`.
  17. ## Parallelization
  18. [thread-loader](https://github.com/webpack-contrib/thread-loader) is enabled by default when the machine has more than 1 CPU cores. This can be turned off by setting `parallel: false` in `vue.config.js`.
  19. ## Installing in an Already Created Project
  20. ``` sh
  21. vue add babel
  22. ```
  23. ## Injected webpack-chain Rules
  24. - `config.rule('js')`
  25. - `config.rule('js').use('babel-loader')`
  26. - `config.rule('js').use('cache-loader')`