- 添加 jenkins 构建环境配置,
This commit is contained in:
parent
6d93e6cec8
commit
45874e36d3
@ -4,9 +4,13 @@ import pageRoutes from './router.config';
|
||||
import webpackPlugin from './plugin.config';
|
||||
import defaultSettings from '../src/defaultSettings';
|
||||
import slash from 'slash2';
|
||||
import proxy from './proxy';
|
||||
|
||||
const { pwa, primaryColor } = defaultSettings;
|
||||
const { NODE_ENV, APP_TYPE, TEST } = process.env;
|
||||
const { NODE_ENV, APP_TYPE, TEST, BASE_PATH } = process.env;
|
||||
|
||||
// 用于控制,部署非跟目录下
|
||||
const basePath = BASE_PATH ? BASE_PATH : '';
|
||||
|
||||
const plugins = [
|
||||
[
|
||||
@ -60,10 +64,8 @@ if (APP_TYPE === 'site') {
|
||||
|
||||
export default {
|
||||
// add for transfer to umi
|
||||
// base: '/adsf',
|
||||
// runtimePublicPath: true,
|
||||
base: '/admin-web/',
|
||||
publicPath: '/admin-web/',
|
||||
base: basePath,
|
||||
publicPath: basePath,
|
||||
plugins,
|
||||
define: {
|
||||
APP_TYPE: APP_TYPE || '',
|
||||
@ -83,18 +85,7 @@ export default {
|
||||
'@antv/data-set': 'DataSet',
|
||||
bizcharts: 'BizCharts',
|
||||
},
|
||||
proxy: {
|
||||
'/admin-api/': {
|
||||
target: 'http://180.167.213.26:18083/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {},
|
||||
},
|
||||
'/server/api/': {
|
||||
target: 'https://preview.pro.ant.design/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/server': '' },
|
||||
},
|
||||
},
|
||||
proxy: proxy(NODE_ENV, basePath),
|
||||
ignoreMomentLocale: true,
|
||||
lessLoaderOptions: {
|
||||
javascriptEnabled: true,
|
||||
|
31
admin-web/config/proxy/index.js
Normal file
31
admin-web/config/proxy/index.js
Normal file
@ -0,0 +1,31 @@
|
||||
// development 和 production
|
||||
|
||||
import path from 'path';
|
||||
import proxyDev from './proxy.dev';
|
||||
import proxyProd from './proxy.prod';
|
||||
|
||||
function basePathBuilder(proxys, basePath) {
|
||||
for (const key in proxys) {
|
||||
const proxy = proxys[key];
|
||||
const pathRewrite = proxy.pathRewrite;
|
||||
const newPathRewrite = {};
|
||||
for (const key2 in pathRewrite) {
|
||||
const item = pathRewrite[key2];
|
||||
newPathRewrite[key2] = path.join(basePath, item);
|
||||
}
|
||||
proxy.pathRewrite = newPathRewrite;
|
||||
}
|
||||
return proxys;
|
||||
}
|
||||
|
||||
export default function(NODE_ENV, basePath) {
|
||||
console.log('development', NODE_ENV === 'development');
|
||||
console.log('undefined', NODE_ENV === 'undefined');
|
||||
console.log(NODE_ENV);
|
||||
let proxys = NODE_ENV === 'development' || NODE_ENV === 'undefined' ? proxyDev : proxyProd;
|
||||
if (basePath) {
|
||||
proxys = basePathBuilder(proxys, basePath);
|
||||
}
|
||||
console.log('proxys------>', proxys);
|
||||
return proxys;
|
||||
}
|
14
admin-web/config/proxy/proxy.dev.js
Normal file
14
admin-web/config/proxy/proxy.dev.js
Normal file
@ -0,0 +1,14 @@
|
||||
// 开发环境,的代理配置
|
||||
|
||||
export default {
|
||||
'/admin-api/': {
|
||||
target: 'http://180.167.213.26:18083/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {},
|
||||
},
|
||||
'/server/api/': {
|
||||
target: 'https://preview.pro.ant.design/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/server': '' },
|
||||
},
|
||||
};
|
16
admin-web/config/proxy/proxy.prod.js
Normal file
16
admin-web/config/proxy/proxy.prod.js
Normal file
@ -0,0 +1,16 @@
|
||||
// production 配置文件
|
||||
|
||||
export default {
|
||||
'/admin-api/': {
|
||||
target: 'http://180.167.213.26:18083/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/admin-api': `/admin-web/admin-api`,
|
||||
},
|
||||
},
|
||||
'/server/api/': {
|
||||
target: 'https://preview.pro.ant.design/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/server': '' },
|
||||
},
|
||||
};
|
@ -75,8 +75,8 @@ export default {
|
||||
},
|
||||
],
|
||||
'POST /admin-api/admins/passport/login': (req, res) => {
|
||||
const { password, username } = req.body;
|
||||
if (password === 'admin' && username === 'admin') {
|
||||
const { username } = req.body;
|
||||
if (username === 'admin') {
|
||||
res.send({
|
||||
code: 0,
|
||||
data: {
|
||||
@ -91,7 +91,7 @@ export default {
|
||||
res.send({
|
||||
code: 1000,
|
||||
data: {},
|
||||
message: '账号或密码错误!',
|
||||
message: '账号或密码错误-mock!',
|
||||
});
|
||||
},
|
||||
'POST /api/register': (req, res) => {
|
||||
|
@ -7,7 +7,10 @@
|
||||
"presite": "cd functions && npm install",
|
||||
"start": "cross-env APP_TYPE=site umi dev",
|
||||
"start:no-mock": "cross-env MOCK=none umi dev",
|
||||
"start:admin-web": "cross-env BASE_PATH=/admin-web NODE_ENV=development APP_TYPE=site umi dev",
|
||||
"start:admin-web:no-mock": "cross-env BASE_PATH=/admin-web NODE_ENV=development MOCK=none APP_TYPE=site umi dev",
|
||||
"build": "umi build",
|
||||
"build:admin-web": "cross-env BASE_PATH=admin-web NODE_ENV=production umi build",
|
||||
"site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy && npm run docker:push",
|
||||
"analyze": "cross-env ANALYZE=1 umi build",
|
||||
"lint:style": "stylelint 'src/**/*.less' --syntax less",
|
||||
|
Loading…
Reference in New Issue
Block a user