且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Webpack -- 包含配置文件作为外部资源

更新时间:2022-02-19 22:42:56

require 自动解析 JSON 文件.externals 需要一个字符串来计算,所以你需要对对象进行字符串化:

require automatically parses the JSON file. externals expects a string to evaluate, so you'll need to stringify the object:

externals: {
  'Configurator': JSON.stringify(require('./config/config-dev.json'))
},