且构网

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

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

更新时间:2022-12-05 19:19:01

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'))
},