using app_env to define the api path
This commit is contained in:
@@ -58,6 +58,9 @@ module.exports = merge(baseConfig, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.HotModuleReplacementPlugin()
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
"process.env": "'dev'"
|
||||||
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
const webpack = require('webpack')
|
||||||
const merge = require('webpack-merge')
|
const merge = require('webpack-merge')
|
||||||
const baseConfig = require('./webpack.config.base')
|
const baseConfig = require('./webpack.config.base')
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||||
@@ -38,6 +39,9 @@ module.exports = merge(baseConfig, {
|
|||||||
plugins: [
|
plugins: [
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
filename: 'main.css'
|
filename: 'main.css'
|
||||||
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
"process.env": "'dev'"
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
+11
-1
@@ -1,9 +1,19 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
// TODO: make this one as settings (or find an other solution)
|
// TODO: make this one as settings (or find an other solution)
|
||||||
let path = 'http://' + window.location.hostname + ':8984'
|
// https://dev.to/sanfra1407/how-to-use-env-file-in-javascript-applications-with-webpack-18df
|
||||||
|
// switch (app_env) {
|
||||||
|
// case 'dev':
|
||||||
|
// let path = `http://${window.location.hostname}:8984`
|
||||||
|
// break;
|
||||||
|
// case 'prod':
|
||||||
|
// let path = `http://${window.location.hostname}/api`
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
// let path = 'http://dev.api.gdp.fr'
|
// let path = 'http://dev.api.gdp.fr'
|
||||||
// let path = 'http://localhost:8984'
|
// let path = 'http://localhost:8984'
|
||||||
|
// const
|
||||||
|
let path = 'http://' + window.location.hostname + (window.env === 'prod' ? '/api' : ':8984')
|
||||||
|
|
||||||
export const REST = axios.create({
|
export const REST = axios.create({
|
||||||
baseURL: path,
|
baseURL: path,
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ Vue.use(InfiniteLoading, {
|
|||||||
|
|
||||||
Vue.use(VueScrollTo)
|
Vue.use(VueScrollTo)
|
||||||
|
|
||||||
|
window.env = process.env
|
||||||
|
|
||||||
// sync(store, router) // done. Returns an unsync callback fn
|
// sync(store, router) // done. Returns an unsync callback fn
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
|
|||||||
Reference in New Issue
Block a user