工程配置化设计
工程配置可以让 Dooring
轻松嵌入任何已有系统, 这块也是私有化企业必须熟悉的, 接下来详细介绍一下配置列表.
ts
import path from 'path';
import { defineConfig, IConfig } from 'umi';
// h5基座的配置
import h5Config from './h5.config';
// 编辑器项目的配置
import editorConfig from './editor.config';
// 下载代码工程的配置
import downConfig from './downH5.config';
// dooring版本
const dooringVersion = '3.0.0';
const isDist = false;
// 构建的类型枚举
type BuldType = "h5" | "editor" | "downH5";
const START_ENV:BuldType = process.argv[4] as BuldType;
const lang = process.argv[5];
// 构建环境(测试还是线上)
export const isTest = process.argv[6] === 'test';
const isDev = process.env.NODE_ENV === 'development';
console.log(`------------- ${isTest ? '测试环境' : '正式环境'} ---------------`)
const config = {
"h5": h5Config,
"editor": editorConfig,
"downH5": downConfig
};
export default defineConfig({
...config[START_ENV] as IConfig,
title: START_ENV === 'h5' ? '加载中...' : 'H5-Dooring | 一款强大的H5编辑器',
devtool: isDev ? 'source-map' : 'cheap-module-source-map',
define: {
START_ENV,
lang,
rowHeight: 1,
colCell: 375,
// 微信公众号开发的appid, 主要用于微信分享等
appId: 'xxxx',
// 页面发布域名
domain: isTest ? 'https://h5dooring.online' : 'https://dooring.vip',
// 环境
isTest,
// 资源管理的地址
resourceUrl: isTest ? 'https://h5dooring.online/#/material' : 'https://dooring.vip/#/material',
// 是否开启埋点
openTrack: true,
// 是否展示数据源
showDataSource: !isTest,
// 共公请求的api路径
apiPrefix: isTest ? 'javaApi' : 'api',
},
// hash: true,
locale: {
default: lang === 'out' ? 'en-US' : 'zh-CN',
antd: true,
title: true,
baseNavigator: true,
},
headScripts: [`/** dooringVersion: ${dooringVersion}; */`],
antd: {},
sass: {
implementation: require('node-sass'),
},
externals: {
axios: 'window.axios',
react: 'window.React',
'react-dom': 'window.ReactDOM',
},
// 公共第三方依赖, 注: 下面的cdn链接最好替换成自己服务器的资源地址
scripts: (START_ENV === 'downH5' || isDist) ? [
'https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js',
'https://unpkg.com/react@16.14.0/umd/react.production.min.js',
'https://unpkg.com/react-dom@16.14.0/umd/react-dom.production.min.js',
] : [
'http://cdn.dooring.cn/dr/axios.min.js',
'http://cdn.dooring.cn/dr%2Freact.production.min.js',
'http://cdn.dooring.cn/dr%2Freact-dom.production.min.js',
],
alias: {
components: path.resolve(__dirname, 'src/components/'),
utils: path.resolve(__dirname, 'src/utils/'),
assets: path.resolve(__dirname, 'src/assets/')
},
dva: {
immer: true
},
});