【问题标题】:How to exclude specific file from babel-loader when using vue-cli setup?使用 vue-cli 设置时如何从 babel-loader 中排除特定文件?
【发布时间】:2019-05-06 18:31:39
【问题描述】:

vue.config.js 中有一个选项transpileDependencies 可以配置到node_modules 中的所有模块,应该被转译,尽管node_modules 通常被排除在外。

我正在寻找的是相反的东西: 我有一些第三方代码,它们不在node_modules 内,并且已经作为相当大的 ES2015 UMD 模块提供。 (不必要地)转译这需要相当长的时间,有时根本无法完成。因此,我想将此路径配置为从 babel transpiliation 中排除。将此模块放在node_modules 下目前是没有选择的。

那么有没有一种简单的方法来配置路径不被 babel-loader 排除在外?

【问题讨论】:

    标签: webpack babeljs vue-cli babel-loader


    【解决方案1】:

    也许,你可以使用你的babel.config.js 来忽略 babel 进程

    const path = require('path')
    
    module.exports = {
      presets: [],
      plugins: [],
      exclude: [
        path.resolve('file path')
      ]
    }
    

    看到那里 https://babeljs.io/docs/en/options#ignore

    【讨论】:

      猜你喜欢
      • 2019-07-30
      • 1970-01-01
      • 2021-06-27
      • 2019-01-03
      • 2020-07-13
      • 2019-10-02
      • 2018-12-01
      • 2020-04-30
      • 2017-12-16
      相关资源
      最近更新 更多