I'm trying to exclude but retain external reference to a few JSON files from a webpack build.
I've modified the webpack.config.js to include:
externals: {
"../package.json": "package_json",
"./font.json": "font"
},
This solved some previous errors, but now it seems that the 'font' var is being considered undefined.
Uncaught ReferenceError: font is not defined
The error is referring to this line in the build, where webpack has exported the 'font' var as a module.export:
/!***********************!
!*** external "font" *!
********************/
/**/ function(module, exports) {
module.exports = font;
When comparing the original code to the webpack build, webpack converted this:
var font = require('./font.json'),
Theme = require('./theme'),
style = require('./utils').style;
to this:
'use strict';
var font = __webpack_require__(/*! ./font.json */ 334),
Theme = __webpack_require__(/*! ./theme */ 324),
style = __webpack_require__(/*! ./utils */ 326).style;
Which seems to leave 'font' undefined? How is webpack handling this var value here?
Webpack is somewhat new to me. Any insights into how to resolve this?
I found the solution with json-loader: npmjs.com/package/json-loader