D
D
DarthJS2018-04-24 10:12:18
React
DarthJS, 2018-04-24 10:12:18

How to make dynamic config for React Webpack build?

The bottom line is this:
There is a config for the application, where the host is stored and some other info for the service. I want to take it out so that after I have assembled the build, it has a config folder with a non-minified file, where it would be possible, if necessary, to change the host url ?
How to do it in webpack ?
PS The application uses the standard webpack config creat-react-app of an assembly that has not yet been extracted

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Pavlov, 2019-10-03
@DarthJS

If you just need to copy a file from src to dist and you're using NPM scripts, then something like this:

scripts: {
  "build": "webpack --config webpack.config.js; cp ./src/dynamic-config.json ./dist/."
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question