Passing environment-dependent variables in webpack

后端 未结 15 2163
醉酒成梦
醉酒成梦 2020-11-22 12:46

I\'m trying to convert an angular app from gulp to webpack. in gulp I use gulp-preprocess to replace some variables in the html page (e.g. database name) depending on the NO

15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 13:04

    Just another option, if you want to use only a cli interface, just use the define option of webpack. I add the following script in my package.json :

    "build-production": "webpack -p --define process.env.NODE_ENV='\"production\"' --progress --colors"
    

    So I just have to run npm run build-production.

提交回复
热议问题