Ask for advice! How to configure jenkins build to pass parameters to js

there are three development environments for pc-side projects (dev/test/prod), and there are three jenkins projects. How to configure jenkins to pass parameters to js when building


if you are asking about environment variables, it is recommended that each system add environment variables with the same name, such as ENV=test. Js can be compiled with environment parameters, such as

.
project_path=$(cd `dirname $0`; pwd)

export NODE_ENV=$ENV

./node_modules/.bin/webpack --config webpack.dll.config -p
./node_modules/.bin/webpack --config webpack.config -p

here you can export environment variables directly to the js compilation environment.
then you can judge happily in the program


module.exports = {
    API_URL:process.env.NODE_ENV == "production" ? "http://XXXX/api/":"http://AAAA/api/",
    IMAGE_URL:process.env.NODE_ENV == "production" ?  "http://XXXXX": "http://AAAA"
}
Menu