How can I make webpack not put JSON file in main.bundle.js?

Viewed 112

In CRA (with react-app-rewired, webpack 4), we have JSON files with configuration of application:

src/config.json -

{"settings": true}

This file is used by function to take values:

import config from './config.json';  
getConfig('settings')

When building, this config is stored in main.bundle.js. This is bad, as our customers may want to modify it. How to build it as separate file?

I saw this rule but it is only for Webpack 5:

{
    test: /\.config.json$/i,
    type: "asset/resource",
    generator: {
        filename: "configs/[name][ext]",
    },
},

I thought to store this json in deploy/ folder, but out of src/ imports are not allowed.

0 Answers
Related