Webpack.mix,vue.js - 编译参数(Webpack.mix, vue.js - compilation parameters)
我有一个webpack.mix.js文件(laravel mix),我用它来编译javascript和scss。 它运作良好,但我需要一个动态参数。 现在我有:
//let result = 'https://www.web1.com/'; let result = 'https://stage.web1.com/'; output: { publicPath: result, chunkFilename: 'js/[name].js' },这工作正常,但我不得不在当地主机/舞台/现场版本之间切换时手动更改参数。
我想要做的是运行:
npm run local npm run stage npm run live并且路径参数将被自动插入。
现在,npm运行prod执行此操作:
cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js我怎样才能在最后一行插入一个参数?
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 liveand 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.jsHow can I insert a parameter into this last line?
最满意答案
要展开@ Ohgodwhy的评论:
let result = process.env.NODE_ENV == "production" ? 'https://www.web1.com/' : 'https://stage.web1.com/'To expand on @Ohgodwhy's comment:
let result = process.env.NODE_ENV == "production" ? 'https://www.web1.com/' : 'https://stage.web1.com/'更多推荐
发布评论