分别为开发和线上环境指定不同的main.js文件
This commit is contained in:
parent
19e591c574
commit
2f5b951911
56
src/main-dev.js
Normal file
56
src/main-dev.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import Vue from 'vue'
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from './router/router'
|
||||||
|
import ElementUI from 'element-ui'
|
||||||
|
import 'element-ui/lib/theme-chalk/index.css'
|
||||||
|
import './assets/fonts/iconfont.css'
|
||||||
|
import './assets/css/globel.css'
|
||||||
|
import tableTree from 'vue-table-with-tree-grid'
|
||||||
|
import axios from 'axios'
|
||||||
|
import vueQuillEditor from 'vue-quill-editor'
|
||||||
|
|
||||||
|
import 'quill/dist/quill.core.css' // import styles
|
||||||
|
import 'quill/dist/quill.snow.css' // for snow theme
|
||||||
|
import 'quill/dist/quill.bubble.css' // for bubble theme
|
||||||
|
import timeline from 'element-ui/lib/timeline'
|
||||||
|
import timelineItem from 'element-ui/lib/timeline-item'
|
||||||
|
// 进度条
|
||||||
|
import NProgres from 'nprogress'
|
||||||
|
import 'nprogress/nprogress.css'
|
||||||
|
|
||||||
|
Vue.use(timeline)
|
||||||
|
Vue.use(timelineItem)
|
||||||
|
Vue.use(vueQuillEditor)
|
||||||
|
Vue.component('table-tree', tableTree)
|
||||||
|
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
|
||||||
|
// 为每个ajax请求头挂一个 token 并加载进度条
|
||||||
|
axios.interceptors.request.use(config => {
|
||||||
|
NProgres.start()
|
||||||
|
config.headers.Authorization = sessionStorage.getItem('token')
|
||||||
|
return config
|
||||||
|
})
|
||||||
|
axios.interceptors.response.use(response => {
|
||||||
|
NProgres.done()
|
||||||
|
return response
|
||||||
|
})
|
||||||
|
|
||||||
|
Vue.filter('dataFormat', (time) => {
|
||||||
|
const dt = (new Date(time))
|
||||||
|
const y = dt.getFullYear()
|
||||||
|
const m = (dt.getMonth() + 1 + '').padStart(2, '0')
|
||||||
|
const d = (dt.getDate() + '').padStart(2, '0')
|
||||||
|
const H = dt.getHours().toString().padStart(2, '0')
|
||||||
|
const i = dt.getMinutes().toString().padStart(2, '0')
|
||||||
|
const s = dt.getSeconds().toString().padStart(2, '0')
|
||||||
|
return `${y}-${m}-${d} ${H}:${i}:${s}`
|
||||||
|
})
|
||||||
|
|
||||||
|
Vue.prototype.$http = axios
|
||||||
|
Vue.use(ElementUI)
|
||||||
|
|
||||||
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
new Vue({
|
||||||
|
router,
|
||||||
|
render: h => h(App)
|
||||||
|
}).$mount('#app')
|
56
src/main-prod.js
Normal file
56
src/main-prod.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import Vue from 'vue'
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from './router/router'
|
||||||
|
import ElementUI from 'element-ui'
|
||||||
|
import 'element-ui/lib/theme-chalk/index.css'
|
||||||
|
import './assets/fonts/iconfont.css'
|
||||||
|
import './assets/css/globel.css'
|
||||||
|
import tableTree from 'vue-table-with-tree-grid'
|
||||||
|
import axios from 'axios'
|
||||||
|
import vueQuillEditor from 'vue-quill-editor'
|
||||||
|
|
||||||
|
import 'quill/dist/quill.core.css' // import styles
|
||||||
|
import 'quill/dist/quill.snow.css' // for snow theme
|
||||||
|
import 'quill/dist/quill.bubble.css' // for bubble theme
|
||||||
|
import timeline from 'element-ui/lib/timeline'
|
||||||
|
import timelineItem from 'element-ui/lib/timeline-item'
|
||||||
|
// 进度条
|
||||||
|
import NProgres from 'nprogress'
|
||||||
|
import 'nprogress/nprogress.css'
|
||||||
|
|
||||||
|
Vue.use(timeline)
|
||||||
|
Vue.use(timelineItem)
|
||||||
|
Vue.use(vueQuillEditor)
|
||||||
|
Vue.component('table-tree', tableTree)
|
||||||
|
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
|
||||||
|
// 为每个ajax请求头挂一个 token 并加载进度条
|
||||||
|
axios.interceptors.request.use(config => {
|
||||||
|
NProgres.start()
|
||||||
|
config.headers.Authorization = sessionStorage.getItem('token')
|
||||||
|
return config
|
||||||
|
})
|
||||||
|
axios.interceptors.response.use(response => {
|
||||||
|
NProgres.done()
|
||||||
|
return response
|
||||||
|
})
|
||||||
|
|
||||||
|
Vue.filter('dataFormat', (time) => {
|
||||||
|
const dt = (new Date(time))
|
||||||
|
const y = dt.getFullYear()
|
||||||
|
const m = (dt.getMonth() + 1 + '').padStart(2, '0')
|
||||||
|
const d = (dt.getDate() + '').padStart(2, '0')
|
||||||
|
const H = dt.getHours().toString().padStart(2, '0')
|
||||||
|
const i = dt.getMinutes().toString().padStart(2, '0')
|
||||||
|
const s = dt.getSeconds().toString().padStart(2, '0')
|
||||||
|
return `${y}-${m}-${d} ${H}:${i}:${s}`
|
||||||
|
})
|
||||||
|
|
||||||
|
Vue.prototype.$http = axios
|
||||||
|
Vue.use(ElementUI)
|
||||||
|
|
||||||
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
new Vue({
|
||||||
|
router,
|
||||||
|
render: h => h(App)
|
||||||
|
}).$mount('#app')
|
|
@ -2,5 +2,13 @@ module.exports = {
|
||||||
devServer: {
|
devServer: {
|
||||||
port: 8887,
|
port: 8887,
|
||||||
open: true
|
open: true
|
||||||
|
},
|
||||||
|
chainWebpack: config => {
|
||||||
|
config.when(process.env.NODE_ENV === 'production', config => {
|
||||||
|
config.entry('app').clear().add('./src/main-prod.js')
|
||||||
|
})
|
||||||
|
config.when(process.env.NODE_ENV === 'development', config => {
|
||||||
|
config.entry('add').clear().add('./src/main-dev.js')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user