H
H
houdy222019-10-08 10:19:52
webpack
houdy22, 2019-10-08 10:19:52

How to add a custom parameter to a command in WebPack?

Hello. The situation is this:
There are two APIs, test and combat.
Is it possible to configure webpack in such a way that, for example, when using the npm run build command, a link in the files to the test API is substituted, and when npm run build:production - production?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
houdy22, 2019-10-08
@houdy22

I wrote the following in package.json:

"scripts": {
    "dev:prod": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
    "dev": "cross-env NODE_ENV=test webpack-dev-server --open --hot",
    "build:prod": "cross-env NODE_ENV=production webpack --progress --hide-modules",
    "build": "cross-env NODE_ENV=test webpack --progress --hide-modules"
}

And in the required files, I just check the value of process.env.NODE_ENV

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question