A
A
andrewayder2021-11-23 02:56:49
Vue.js
andrewayder, 2021-11-23 02:56:49

How is set VUE_APP_PROCEDURE=build different from the definition in .env?

Hello, I can declare VUE_APP_PROCEDURE=build in the .env file
and then, for example, from vue.config.js

console.log(process.env.VUE_APP_PROCEDURE); //build
console.log(process.env.VUE_APP_PROCEDURE == "build");  //true
console.log(process.env.VUE_APP_PROCEDURE); //build

But it costs me to create a .env file instead
//package.json
 "scripts": {
    "serve": "set VUE_APP_PROCEDURE=serve & vue-cli-service serve",
    "build": "set VUE_APP_PROCEDURE=build & vue-cli-service build",
}

how do i get it now
console.log(process.env.VUE_APP_PROCEDURE); //build
console.log(process.env.VUE_APP_PROCEDURE == "build");  //fasle
console.log(process.env.VUE_APP_PROCEDURE); //build

What's going wrong...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
resibe, 2021-11-23
@andrewayder

Alternatively, the problem may be in the variable declaration itself,
inside

"set VUE_APP_PROCEDURE=build & vue-cli-service build"
normal cmd (shell) script, set implementation of variables in cmd,
since there are no delimiters at the end of the line in cmd, that is, ";" probably the script after the assignment can read the space set VUE_APP_PROCEDURE=build &before the & (which separates the commands for inline use) and you get not builda build с пробелом
Try this
"build": "set VUE_APP_PROCEDURE=build& vue-cli-service build",

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question