Commit 23c56631 authored by hangjun83's avatar hangjun83

支持多环境打包配置

parent b87383a2
NODE_ENV = 'production'
VUE_APP_ENV = 'prod'
VUE_APP_MOCK = false
BASE_URL= '/adminapi'
......@@ -5,8 +5,13 @@
"author": "Exrick <1012139570@qq.com>",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",
"build": "vue-cli-service build"
"build": "vue-cli-service build",
"dev": "vue-cli-service serve --open --mode dev",
"build:test": "vue-cli-service build --mode beta",
"build:prod": "vue-cli-service build --mode prod",
"lint": "vue-cli-service lint",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e"
},
"dependencies": {
"@mapbox/mapbox-gl-geocoder": "^4.7.1",
......
export default {
/**
* @description 配置显示在浏览器标签的title
*/
title: '管理后台',
/**
* @description token在Cookie中存储的天数,默认1天
*/
cookieExpires: 1,
/**
* @description 是否使用国际化,默认为false
* 如果不使用,则需要在路由中给需要在菜单中展示的路由设置meta: {title: 'xxx'}
* 用来在菜单中显示文字
*/
useI18n: true,
/**
* @description api请求基础路径
*/
baseUrl: {
dev: '',
pro: 'http://localhost:8211/'
},
/**
* @description 默认打开的首页的路由name值,默认为home
*/
homeName: 'home',
/**
* @description 需要加载的插件
*/
plugin: {
'error-store': {
showInHeader: true, // 设为false后不会在顶部显示错误日志徽标
developmentOff: true // 设为true后在开发环境不会收集错误信息,方便开发中排查错误
}
}
}
\ No newline at end of file
......@@ -3,12 +3,18 @@ import { getStore, setStore } from './storage';
import { router } from '../router/index';
import { Message } from 'view-design';
import Cookies from 'js-cookie';
import config from '@/config'
const { dev, pro } = config.baseUrl;
// 统一请求路径前缀
let base = '/adminapi';
// 超时设定
axios.defaults.timeout = 15000;
axios.interceptors.request.use(config => {
config.baseURL = process.env.NODE_ENV === "development" ? dev : pro;
return config;
}, err => {
Message.error('请求超时');
......
......@@ -2,11 +2,12 @@
.operation {
margin-bottom: 2vh;
overflow-y: auto;
height:100%
}
.content {
margin-bottom: 2vh;
height: 56vh;
height: 100%;
width: 50vw;
}
......
const CompressionPlugin = require('compression-webpack-plugin');
const path = require("path");
const resolve = dir => {
return path.join(__dirname, dir);
};
// 项目部署基础
// 默认情况下,我们假设你的应用将被部署在域的根目录下,
// 例如:https://www.my-app.com/
// 默认:'/'
// 如果您的应用程序部署在子路径中,则需要在这指定子路径
// 例如:https://www.foobar.com/my-app/
// 需要将它改为'/my-app/'
// iview-admin线上演示打包路径: https://file.iviewui.com/admin-dist/
const BASE_URL =
process.env.NODE_ENV === "production" ? "http://localhost:8399/" : "/";
module.exports = {
devServer: {
host: '127.0.0.1',
port: 9999,
proxy: {
'/adminapi': {
target: 'http://127.0.0.1:8211', // 请求本地 需要xboot后端项目
target: 'http://127.0.0.1:8211',
ws: true
},
}
},
publicPath: BASE_URL,
// tweak internal webpack configuration.
// see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
// 如果你不需要使用eslint,把lintOnSave设为false即可
lintOnSave: true,
//兼容低版本浏览器不能解析es6语法,先安装需要的包
// npm install -D babel-loader@7 babel-core babel-preset-env webpack
// 打包时不生成.map文件 避免看到源码
productionSourceMap: false,
// 部署优化
......@@ -35,6 +64,28 @@ module.exports = {
// vuedraggable: 'vuedraggable',
// viewerjs: 'Viewer'
// },
module: {
rules: [
{
test: /\.m?js$/,
//exclude用下面配置的话,默认是过滤不编译node_modules 路径下的文件
//exclude: /(node_modules|bower_components)/,
//include 指定需要编译的文件路径
include: [
resolve("src"),
resolve("node_modules/tree-table-vue/lib"),
resolve("node_modules/v-org-tree/dist"),
resolve("node_modules/view-design/src/locale")// 我的是把iview 升级为4的版本,所以是view-design包,之前是iview 包
],
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"]
}
}
}
]
},
// GZIP压缩
plugins: [
new CompressionPlugin({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment