Apparently, the file loader emits the path to where the file was downloaded, and not the file itself. So
import * as config from '../config.json';
creating config on a line containing the file path is the correct behavior.
Regarding move-file-loader, since I use it with json-loader, the contents of the “moved” file are actually the definition of the TypeScript module, and it seems to still load the attached version of the file, not the “copied” version.
These ideas lead me to the following solution: First of all, we copy the JSON files using the file loader in the Webpack configuration:
module: { rules: [
Then we import the file path sent by the file loader using TypeScript require syntax
const configFile = require('../config.json');
This import method does not require a JSON definition file, which I mention in my question.
Finally, we can upload the file from our path to the file loader via an HTTP GET:
http.get(configFile).map(res => res.json()).catch((error: any): any => {
where config is the parsed content of the JSON file.
I will not mark this as an answer right away if someone knows how this works without HTTP.
alan
source share