【问题标题】:webpack.externals relative path causes Unexpected tokenwebpack.externals 相对路径导致 Unexpected token
【发布时间】:2021-03-18 03:53:24
【问题描述】:

当我将相对路径添加到webpack.externals 数组时,输出文件包含:module.exports = ../path; 导致错误:意外令牌。

//webpack.config.js
{
 externals: ['../path']
}
//input.ts
import something from '../path';
//output.js
module.exports = ../path;

【问题讨论】:

    标签: typescript webpack webpack-4


    【解决方案1】:

    通过使用函数而不是对象来修复

    {
     externals:[  
       function(..){
         //checking
         return callback(null, "commonjs path")
       }
     ]
    }
    

    【讨论】:

      猜你喜欢
      • 2017-06-10
      • 1970-01-01
      • 2019-11-29
      • 1970-01-01
      • 1970-01-01
      • 2019-11-08
      • 1970-01-01
      • 2018-09-29
      • 2017-10-14
      相关资源
      最近更新 更多