Timeline for Using Environment Variables with Vue.js
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 30, 2021 at 3:59 | comment | added | Steven Almeroth | "Note that because the plugin does a direct text replacement, the value given to it must include actual quotes inside of the string itself. Typically, this is done either with alternate quotes, such as '"production"', or by using JSON.stringify('production')." webpack.js.org/plugins/define-plugin/#usage | |
Jun 3, 2020 at 22:15 | comment | added | fred |
The key for me was prefixing with VUE_APP_ in both .env AND in the file.vue
|
|
Feb 13, 2019 at 12:22 | comment | added | Nodira |
@Aaron McKeehan For example, I added, if (process.env.NODE_ENV === 'development') { module.exports.plugins = (module.exports.plugins || []).concat([ new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '"development"', DEBUG_MODE: true, ROOT_API: '"http://localhost:8080/"' } }) ]); } and in Setting.vue I want to add this ROOT_API variable in my post request: axios .post(ENVIRONMENT_VARIABLE_HERE??/api/users/me/change-password ){...}. Please give me advice, I'm not pro in how webpack works
|
|
Feb 13, 2019 at 12:21 | comment | added | Nodira | Aaron McKeehan, I did the same addition to my webpack.config as you advised. But, how can I use that variable I wrote for development in my vue component for request beginning? | |
Dec 6, 2018 at 23:07 | comment | added | slowFooMovement |
I'm moving toward's Vue CLI 3 for future projects, but ran into the same problem on an App I built with the webpack-simple install. I expanded on your logic a little bit here and just created an "else" condition in which I just pass the process.env.NODE_ENV value into the DefinePlugin args.
|
|
Sep 18, 2018 at 15:10 | history | answered | Aaron McKeehan | CC BY-SA 4.0 |