Commit e537da12 authored by 前端-许佳敏's avatar 前端-许佳敏

chore: 优化构建方式,加入yapi的id转化插件, 去除splitChunk代码分割

parent 03381d6e
......@@ -35,3 +35,6 @@ src/services/*Api.ts
src/services/*Api
config/router.config.json
# 忽略yapi生成的文件
yapi_hashmaps.json
module.exports = [
{ name: 'LogisticsV2', token: '732fb8e33970ff5dee830423a630e8e85c3ef3293abba7581b16749dfce8608b', categoryIds: [0], }, // 物流能力v2
{ name: 'ProductV2', token: 'df37f2a0e3829c4288708ae211920bdbdee55e5e2f48b1e8cf7d1925ac618d9a', categoryIds: [0], }, // 商品服务V2
{ name: 'TemplateV2', token: '7bb5578bc50e4e7935cbc146a2192e978053d5380cc96fcfdc0a754cfe885ec5', categoryIds: [0], }, // 页面模板服务V2
{ name: 'PayV2', token: '4b5f2f2d42f0774b61074d69d5d756c725ba067d9dafe2c3785f592ae85d1696', categoryIds: [0], }, // 支付服务
{ name: 'SearchV2', token: 'f3e6ec26764f54d06ba33f487ff42d7debeaef397e51dc395040447737eb2e66', categoryIds: [0], }, // 搜索服务V2
{ name: 'PurchaseV2', token: '84c81ef877863ad4e2c0ebb2c3b3e80f9539420f2fc0828ef33f5159e8423b2c', categoryIds: [0] }, // 采购服务V2
{ name: 'SettleV2', token: 'fed8d45aa92e7f0e382a3dcc5e0ef63f13f0badeabab76d6a6e2db49aa403346', categoryIds: [0] },
{ name: 'TransactionV2', token: '3ad04435494d01c359b9f07948338e019133a3e6c0fccdbe1bc3adc19cf1e0b1', categoryIds: [0] }, // 交易服务V2
{ name: 'ContractV2', token: 'bbf1f327cfe7c59d1e7fd9c5d25119829dd79d238b1f1c79ed97331e220721a4', categoryIds: [0] }, // 合同能力V2
{ name: 'OrderNewV2', token: '89202a7986a86e7306925203d7eea0d999af8bb98d70a210d217a470d44b2dba', categoryIds: [0], }, //订单服务V2 New
{ name: 'MemberV2', token: 'be87c2732cb1253f82fe6c27d6cca9982c7dca9b384e46cc2e797b5835846834', categoryIds: [0]}, //会员服务 V2
{ name: 'ReportV2', token: 'dab50c384c27f1c981a03f2c44ad76d1e7e1f60b4520bd279cea67f5cf146cee', categoryIds: [0]}, // 报表服务v2 首页
{ name: 'EnhanceV2', token: '71b97616a81866ade2731437ca121e288b1dd8331dce4b5c1ccaacb176c16580', categoryIds: [0], }, // 加工服务v2
{ name: 'MessageV2', token: '69a667ec9861e8bdc25b89238d0b908a2123d9fce26e72fec3cdf6cd0b1f2681', categoryIds: [0], }, // 消息中心v2
{ name: 'MarketingV2', token: 'f6d5cee2383ca203dfa2882b84dfa02a1d79de3c3ad892b42f030437fdc5ea21', categoryIds: [0], }, // 营销能力
{ name: 'AfterServiceV2', token: '58748fc89dcdb33ec5cac520c00293ba92abca362a8ddb979df589effd0db9bd', categoryIds: [0], }, // 售后能力V2
{ name: 'ManageV2', token: '9ee3a1cb5a73ca02935e70debeda5bde0464f2fe1eb32c25855fd8acff9f68f2', categoryIds: [0] }, // 平台后台v2
]
......@@ -113,7 +113,7 @@ const config: any = {
defaultSizes: 'parsed', // stat // gzip
},
inlineLimit: 10000,
chunks: isProduction && ['vendors', 'umi'],
// chunks: isProduction && ['styles', 'vendors', 'umi', 'services'],
chainWebpack: function(config, { webpack }) {
// config.plugin('case-sensitive-paths-webpack-plugin').use(CaseSensitivePathsWebpackPlugins)
config.module
......@@ -129,27 +129,39 @@ const config: any = {
.use('@svgr/webpack')
.loader(require.resolve('@svgr/webpack'));
isProduction &&
config.merge({
optimization: {
minimize: true,
splitChunks: {
chunks: 'all',
minSize: 30000,
minChunks: 3,
automaticNameDelimiter: '.',
cacheGroups: {
vendor: {
name: 'vendors',
test({ resource }) {
return /[\\/]node_modules[\\/]/.test(resource);
},
priority: 10,
},
},
},
},
});
// isProduction &&
// config.merge({
// optimization: {
// minimize: true,
// splitChunks: {
// chunks: 'all',
// minSize: 30000,
// minChunks: 3,
// automaticNameDelimiter: '.',
// cacheGroups: {
// vendor: {
// name: 'vendors',
// test({ resource }) {
// return /[\\/]node_modules[\\/]/.test(resource);
// },
// priority: 10,
// },
// services: {
// name: 'services',
// test({ resource }) {
// return /[\\/]services[\\/]/.test(resource)
// }
// },
// styles: {
// name: 'styles',
// test: /\.(le|c)ss$/,
// chunks: 'all',
// enforce: true,
// }
// },
// },
// },
// });
},
cssLoader: {
localsConvention: 'camelCase', // 将style中的class由 .foo-body 转化为fooBody调用
......@@ -171,7 +183,8 @@ const config: any = {
* 会自动添加到网页html的顶部
*/
metas: [],
plugins: [], // 配置项的名字通常是插件名去掉 umi-plugin- 或 @umijs/plugin 前缀。
plugins: [
], // 配置项的名字通常是插件名去掉 umi-plugin- 或 @umijs/plugin 前缀。
proxy,
// ssr: {},
// exportStatic: {},
......
......@@ -101,6 +101,7 @@ module.exports = {
BACK_GATEWAY: 'http://10.0.1.220:8100',
USE_ROUTE_CONFIG: true,
SOCKET_URL: 'ws://10.0.1.220:8100',
YAPI_URL: 'http://10.0.0.25:4000/',
ssh: JSON.stringify({
user: "root",
// Password optional, prompted if none given
......@@ -124,6 +125,7 @@ module.exports = {
BACK_GATEWAY: 'http://10.0.1.220:8100',
USE_ROUTE_CONFIG: true,
SOCKET_URL: 'ws://10.0.1.220:8100',
YAPI_URL: 'http://10.0.0.25:4000/',
ssh: JSON.stringify({
user: "root",
// Password optional, prompted if none given
......@@ -164,5 +166,29 @@ module.exports = {
// Passive mode is forced (EPSV command is not sent)
forcePasv: true
})
},
"v2-demo": {
SITE_ID: '1',
BACK_GATEWAY: 'http://lx-gateway.shushangyun.com:13880',
USE_ROUTE_CONFIG: true,
SOCKET_URL: 'ws://lx-gateway.shushangyun.com:13880',
YAPI_URL: 'http://10.0.0.25:4000/',
ssh: JSON.stringify({
user: "root",
// Password optional, prompted if none given
password: "123456",
host: "10.0.0.17",
port: 22,
localRoot: path.resolve('./dist/'),
remoteRoot: "/home/www/v2scm-member/",
// include: ["*", "**/*"], // this would upload everything except dot files
include: ["*"],
// e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)
// exclude: ["dist/**/*.map", "node_modules/**", "node_modules/**/.*", ".git/**"],
// delete ALL existing files at destination before uploading, if true
deleteRemote: true,
// Passive mode is forced (EPSV command is not sent)
forcePasv: true
})
}
}
......@@ -8,9 +8,11 @@
"upload:study": "cross-env PRO_ENV=study taskName=upload yarn scripts:build",
"upload:v2": "cross-env PRO_ENV=v2 taskName=upload yarn scripts:build",
"upload:v2Preview": "cross-env PRO_ENV=v2Preview taskName=upload yarn scripts:build",
"upload:v2-demo": "cross-env PRO_ENV=v2-demo taskName=upload yarn scripts:build",
"upload:v2scm": "cross-env PRO_ENV=v2scm taskName=upload yarn scripts:build",
"upload:v2Test": "cross-env PRO_ENV=v2Test taskName=upload yarn scripts:build",
"api": "god-ytt",
"testApi": "cross-env PRO_ENV=v2 god-ytt",
"scripts:build": "node scripts/run",
"scripts:build-yxc": "node scripts/run http://yxc-web-demo.shushangyun.com/api",
"start:dev": "cross-env NODE_OPTIONS=--max_old_space_size=4096 umi dev",
......@@ -18,7 +20,7 @@
"clean": "rimraf node_modules",
"start": "yarn api && yarn scripts:build && cross-env NODE_OPTIONS=--max_old_space_size=4096 umi dev",
"build": "yarn api && yarn scripts:build && yarn build:clean",
"build:yxc": "yarn api && yarn scripts:build-yxc && umi build",
"build:yxc": "yarn api && yarn scripts:build-yxc && umi bu ild",
"build:analyze": "cross-env NODE_OPTIONS=--max_old_space_size=16384 ANALYZE=1 umi build",
"build:dev": "pm2 start scripts/devServer.js",
"build:clean": "cross-env NODE_OPTIONS=--max_old_space_size=16384 umi build",
......@@ -27,8 +29,9 @@
"build:10": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.10:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.0.10:9400 yarn build",
"build:study": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.207:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.207:9400 yarn build",
"build:v2": "cross-env PRO_ENV=v2 yarn build",
"build:v2Preview": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.220:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.220:9400 yarn build",
"build:v2scm": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.220:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.220:9400 yarn build",
"build:v2Preview": "cross-env PRO_ENV=v2Preview yarn build",
"build:v2scm": "cross-env PRO_ENV=v2scm yarn build",
"build:v2-demo": "cross-env PRO_ENV=v2-demo yarn build",
"build:v2Test": "cross-env SITE_ID=1 BACK_GATEWAY=http://lx-pre-gateway.shushangyun.com USE_ROUTE_CONFIG=false SOCKET_URL=ws://lx-pre-gateway.shushangyun.com yarn build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
......@@ -41,8 +44,8 @@
"start:study": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.207:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.207:9400 yarn start",
"start:25": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.25:8100 USE_ROUTE_CONFIG=true SOCKET_URL=ws://10.0.0.25:9400 yarn start",
"start:v2": "cross-env PRO_ENV=v2 yarn start",
"start:v2Preview": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.220:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.220:9400 yarn start",
"start:v2scm": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.220:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.220:9400 yarn start"
"start:v2Preview": "cross-env PRO_ENV=v2Preview yarn start",
"start:v2scm": "cross-env PRO_ENV=v2scm yarn start"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
......@@ -103,6 +106,7 @@
"sortablejs": "^1.12.0",
"typescript": "^3.9.7",
"umi": "3.5.20",
"umi-plugin-yapi": "1.4.0",
"video-react": "^0.14.1",
"yorkie": "^2.0.0"
},
......@@ -125,7 +129,7 @@
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"god-upload-scp": "1.0.1",
"god-yapi2ts": "^1.0.0",
"god-yapi2ts": "1.11.0",
"gulp": "^4.0.2",
"gulp-git": "^2.10.1",
"hard-source-webpack-plugin": "^0.13.1",
......
......@@ -4,25 +4,7 @@ if (!process.env.YAPI_URL) {
throw 'yapi链接不存在'
}
const tokenList = [
{ name: 'LogisticsV2', token: '732fb8e33970ff5dee830423a630e8e85c3ef3293abba7581b16749dfce8608b', categoryIds: [0], }, // 物流能力v2
{ name: 'ProductV2', token: 'df37f2a0e3829c4288708ae211920bdbdee55e5e2f48b1e8cf7d1925ac618d9a', categoryIds: [0], }, // 商品服务V2
{ name: 'TemplateV2', token: '7bb5578bc50e4e7935cbc146a2192e978053d5380cc96fcfdc0a754cfe885ec5', categoryIds: [0], }, // 页面模板服务V2
{ name: 'PayV2', token: '4b5f2f2d42f0774b61074d69d5d756c725ba067d9dafe2c3785f592ae85d1696', categoryIds: [0], }, // 支付服务
{ name: 'SearchV2', token: 'f3e6ec26764f54d06ba33f487ff42d7debeaef397e51dc395040447737eb2e66', categoryIds: [0], }, // 搜索服务V2
{ name: 'PurchaseV2', token: '84c81ef877863ad4e2c0ebb2c3b3e80f9539420f2fc0828ef33f5159e8423b2c', categoryIds: [0] }, // 采购服务V2
{ name: 'SettleV2', token: 'fed8d45aa92e7f0e382a3dcc5e0ef63f13f0badeabab76d6a6e2db49aa403346', categoryIds: [0] },
{ name: 'TransactionV2', token: '3ad04435494d01c359b9f07948338e019133a3e6c0fccdbe1bc3adc19cf1e0b1', categoryIds: [0] }, // 交易服务V2
{ name: 'ContractV2', token: 'bbf1f327cfe7c59d1e7fd9c5d25119829dd79d238b1f1c79ed97331e220721a4', categoryIds: [0] }, // 合同能力V2
{ name: 'OrderNewV2', token: '89202a7986a86e7306925203d7eea0d999af8bb98d70a210d217a470d44b2dba', categoryIds: [0], }, //订单服务V2 New
{ name: 'MemberV2', token: 'be87c2732cb1253f82fe6c27d6cca9982c7dca9b384e46cc2e797b5835846834', categoryIds: [0]}, //会员服务 V2
{ name: 'ReportV2', token: 'dab50c384c27f1c981a03f2c44ad76d1e7e1f60b4520bd279cea67f5cf146cee', categoryIds: [0]}, // 报表服务v2 首页
{ name: 'EnhanceV2', token: '71b97616a81866ade2731437ca121e288b1dd8331dce4b5c1ccaacb176c16580', categoryIds: [0], }, // 加工服务v2
{ name: 'MessageV2', token: '69a667ec9861e8bdc25b89238d0b908a2123d9fce26e72fec3cdf6cd0b1f2681', categoryIds: [0], }, // 消息中心v2
{ name: 'MarketingV2', token: 'f6d5cee2383ca203dfa2882b84dfa02a1d79de3c3ad892b42f030437fdc5ea21', categoryIds: [0], }, // 营销能力
{ name: 'AfterServiceV2', token: '58748fc89dcdb33ec5cac520c00293ba92abca362a8ddb979df589effd0db9bd', categoryIds: [0], }, // 售后能力V2
{ name: 'ManageV2', token: '9ee3a1cb5a73ca02935e70debeda5bde0464f2fe1eb32c25855fd8acff9f68f2', categoryIds: [0] }, // 平台后台v2
]
const tokenList = require('./api.config')
const getConfigMap = (tokens) => tokens.map(v => ({
serverUrl: process.env.YAPI_URL,
......@@ -30,6 +12,7 @@ const getConfigMap = (tokens) => tokens.map(v => ({
reactHooks: {
enabled: false,
},
yapiMaps: true,
outputFilePath: `src/services/${v.name}Api`,
requestFunctionFilePath: '@/utils/request',
dataKey: 'data',
......
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