Reputation: 2253
I have a webpack.mix.js file (laravel mix) that I use for compiling javascript and scss. It works well, but I need a dynamic parameter. Right now I have:
//let result = 'https://www.web1.com/';
let result = 'https://stage.web1.com/';
output: {
publicPath: result,
chunkFilename: 'js/[name].js'
},
This works fine, but I have to change the parameter manually when I switch between the localhost/stage/live version.
What I would like to do is to run:
npm run local
npm run stage
npm run live
and the path parameter would be inserted automatically.
Right now, the npm run prod executes this:
cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
How can I insert a parameter into this last line?
Upvotes: 0
Views: 1087
Reputation: 25211
To expand on @Ohgodwhy's comment:
let result = process.env.NODE_ENV == "production" ?
'https://www.web1.com/' :
'https://stage.web1.com/'
Upvotes: 2