Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


VueJS Boilerplate

03 Jun 2020 » programming
cat > vue.config.js <<EOF
module.exports = {
    // options...
    runtimeCompiler: true,
    devServer: {
        disableHostCheck: true,
        watchOptions: {
            poll: true
        },
        public: 'http://codeserver:8082'
    },
}
EOF

Vue config + env

cat .env.local
PUBLIC_URL=http://hostname:ip
VUE_APP_BASEURL=http://hostname:ip
vue.config.js
...
public: process.env.PUBLIC_URL
...

filename.vue
...
var baseurl = process.env.VUE_APP_BASEURL
...

Axios

# kickstart
#https://www.npmjs.com/package/vue-axios
npm install --save axios vue-axios

main.js

import axios from 'axios'
import VueAxios from 'vue-axios'
 
Vue.use(VueAxios, axios)
import axios from 'axios'

const instance = axios.create({
   baseURL: process.env.VUE_APP_BACKEND 
})

export default instance

```