Is there any way to pass parameters to the npm script when webpack is packaged?

now there is a project packaged when the address of the static resource is written on the dead line, so the static resource cannot be accessed during the test environment.

so you want to control the address when packaging through the command line, such as npm run build-- env=box1 , and then get the passed env parameter

through argv.
const args = process.argv.splice(2);
let env = ""

args.map(item=>{
    let params = item.split("=");
    if(params[0] == "env") {
        env = params[1]
    }
})

module.exports = {
    DEV: "dev",
    PRODUCT: "product",
    SERVER_URL: `https://static${env ? "-" + env: ""}.xxxx.com/xxx/`//
}

as a result, there is no env=box1, in the args that I want, so I have to manually add the env to the cli every time I pack it, but it"s easy to forget

so is there any way to get the parameter env=box1 ?

`npm run build --env=box1`
`npm run build --env=box2`
...
`npm run build --env=qc1`
`npm run build --env=qc2`
...
Mar.29,2021

here is the official solution of webpack. You can send it directly: ides/environment-variables/" rel=" nofollow noreferrer "> https://webpack.js.org/guides.

.
webpack --env.NODE_ENV=local --env.production --progress
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e8ec-2c428.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e8ec-2c428.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?