load json file at runtime in webpack

Viewed 932

I am new into Webpack and my requirement is to include any JSON file at runtime not in bundled file using webpack.

Scenario: --I have to write code like this in webpack.config.js:

externals: {
    Conf: JSON.stringify(require('./env/env-dev.json'))
}

In another Component file, we require like this:--

    const config = require('Conf'); 

But in this code env-dev.json has loaded in bundled file when we require 'Conf' under any component module.

But when we don't require it in any component, then this env-dev.json will not be loaded in bundled file.

But my requirement is don't want to include this file under bundled file. and use it any code.

Please help me out..

1 Answers
Related