My Angular app is configured with a JSON file. I was loading it via an HTTP GET, but recently decided to include it directly by adding JSON support to TypeScript with a Definition file:
declare module "*.json" {
const value: any;
export default value;
}
And then importing it where needed:
import * as config from '../config.json';
This works great; config is the JSON object itself.
The problem is that I'm bundling with Webpack and I want the JSON file to be in the package, but not bundled with anything else, that is, config.json should be its own file in the package, rather than being bundled with other files.
I tried doing this with file-loader and move-file-loader:
module: {
rules: [
// ...
{
test: /\.json$/,
loader: 'file-loader?name=[name].json'
}
// OR
{
test: /\.json$/,
loader: "move-file-loader?name=[name].json!json-loader"
}
// ...
]
}
This prevents the JSON file from being bundled and places it where I want it in the package, but it also makes config become the relative path to the JSON file, i.e., "./config.json", rather than the JSON object itself.
Any thoughts on why this might be?