Commit 0e855073 authored by 邓晓峰's avatar 邓晓峰

feat: rewrite webpack config and openapi

parent 51c50661
Pipeline #23618 skipped with stages
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -54,10 +54,10 @@ module.exports = {
controlComponents: ['Input'],
},
],
// 'jsx-a11y/label-has-for': 0,
// 'jsx-a11y/mouse-events-have-key-events': 2,
// 'jsx-a11y/role-has-required-aria-props': 2,
// 'jsx-a11y/role-supports-aria-props': 2,
'jsx-a11y/label-has-for': 0,
'jsx-a11y/mouse-events-have-key-events': 2,
'jsx-a11y/role-has-required-aria-props': 2,
'jsx-a11y/role-supports-aria-props': 2,
'jsx-a11y/no-noninteractive-element-interactions': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/no-static-element-interactions': 0,
......
......@@ -12,3 +12,4 @@ npm-debug.log
src/umi
.vscode
civbase
src/components/OpenApi
## [0.0.14](https://g.civnet.cn:8443/test/maintenance/compare/v0.0.20...v0.0.14) (2021-02-11)
### Bug Fixes
* alarm label ([ed4cf05](https://g.civnet.cn:8443/test/maintenance/commits/ed4cf05c534fe19f46194137ef8a4b12f504c0f4))
* alarm notice message ([eb4e979](https://g.civnet.cn:8443/test/maintenance/commits/eb4e9796a0c507c5943cc4156ac0c36bcae1421c))
* api request bug ([4bfa0ce](https://g.civnet.cn:8443/test/maintenance/commits/4bfa0ce4cd6ff297da1d1ab7915558c8c21ad98a))
* app.js initConfig bug ([8a13e30](https://g.civnet.cn:8443/test/maintenance/commits/8a13e303dbe26525d2cbf4e8a109d26fc8ae7baf))
* basic layout load mircro bug ([a5f82f1](https://g.civnet.cn:8443/test/maintenance/commits/a5f82f10f51ecd73b0ff4ac3ee703914e9904ba0))
* bug ([6aa8abe](https://g.civnet.cn:8443/test/maintenance/commits/6aa8abe372900a899a05f96325decf26d5dca552))
* bug ([d9d234f](https://g.civnet.cn:8443/test/maintenance/commits/d9d234fd850f7a19a5e49b2113b8df78b7d43518))
* eslint:fix errors ([fb2c457](https://g.civnet.cn:8443/test/maintenance/commits/fb2c45788d4fb2e6eb4a4d2be9d1e3b356a2c648))
* fix parseHisTomessage ([c10acdc](https://g.civnet.cn:8443/test/maintenance/commits/c10acdc2e37dbd2f6744e8603da08ed720f6ae92))
* generMenu bug ([804d1d0](https://g.civnet.cn:8443/test/maintenance/commits/804d1d02237470fb3768197d7c020a5730b51923))
* gitlab-ci.yml ([2c71162](https://g.civnet.cn:8443/test/maintenance/commits/2c7116270e08c9fec05ca1a2388c603825eb0b0f))
* iframe load error ([687b27f](https://g.civnet.cn:8443/test/maintenance/commits/687b27ff3b1cb5f3e1e37ed5253ba597c40f37e4))
* lint code style ([75d723a](https://g.civnet.cn:8443/test/maintenance/commits/75d723a0cfba2184270897e16b8d6e5873211fcb))
* lint code style ([4b6631c](https://g.civnet.cn:8443/test/maintenance/commits/4b6631cd6aa561d7c701878ac10282f49574ca2a))
* load source bug ([6b51167](https://g.civnet.cn:8443/test/maintenance/commits/6b51167c88fc3ad16ff5eead38ade7a7588254b8))
* load source bug ([85ce351](https://g.civnet.cn:8443/test/maintenance/commits/85ce3519cf7ecf0a8331aa19fcee96a26f40c7cb))
* menu load bug ([d9fe282](https://g.civnet.cn:8443/test/maintenance/commits/d9fe28267e368734c2aeefcda12d814f6b365393))
* message alarm ([6921fe7](https://g.civnet.cn:8443/test/maintenance/commits/6921fe7f27654048902d95657221a66acd52966f))
* message bug ([7be1624](https://g.civnet.cn:8443/test/maintenance/commits/7be1624e2e80d2613627979d0a8f70599255da4b))
* message format ([718a8ed](https://g.civnet.cn:8443/test/maintenance/commits/718a8ed5cd4feb6ad194f98a3fca441cf1f78e45))
* message format ([d82b2ed](https://g.civnet.cn:8443/test/maintenance/commits/d82b2ed11d51ce1f49ec8f7c25006fdbf8b6d1e5))
* message format bug ([ff1a737](https://g.civnet.cn:8443/test/maintenance/commits/ff1a737546d3f45bd4c3e78ef14445b2e179747e))
* message format bug ([21fad26](https://g.civnet.cn:8443/test/maintenance/commits/21fad2633dc378ce823d13bc3770b2da82500658))
* message throme ([9c0fcfd](https://g.civnet.cn:8443/test/maintenance/commits/9c0fcfdb12992c105e9326f6426de44cfd64d866))
* message throme ([649d67b](https://g.civnet.cn:8443/test/maintenance/commits/649d67bfe9d06f29ab46a2ed68bc2dafcc0df90e))
* micro sanbox ([eeb667f](https://g.civnet.cn:8443/test/maintenance/commits/eeb667fe4521395e40ed134d7f9e912aea837e78))
* notice bug ([7537eaf](https://g.civnet.cn:8443/test/maintenance/commits/7537eaf797b0c26060b32e289093a8fc01589b6c))
* package husky hooks ([196ba8f](https://g.civnet.cn:8443/test/maintenance/commits/196ba8f44db460f7487fae890203cc69b407ac77))
* package.json scripts build ([5294c9a](https://g.civnet.cn:8443/test/maintenance/commits/5294c9a47930ff606c5cf4c56530e304fff63e7e))
* pretter layout/basiclayout.js format code style ([30374c5](https://g.civnet.cn:8443/test/maintenance/commits/30374c508fe868ef7e787e4aeff59f730170adf2))
* securityLayout ([2cd33b8](https://g.civnet.cn:8443/test/maintenance/commits/2cd33b885ff30b02f4fa52143e612d1295792879))
* 云平台下切换站点bug ([d48f715](https://g.civnet.cn:8443/test/maintenance/commits/d48f71519bc0682a7a7aceb50c4be17b6709efea))
* 云平台下切换站点bug ([c19cee1](https://g.civnet.cn:8443/test/maintenance/commits/c19cee1f004c17a176fa1cdfe9c53630eeeccc91))
* 修复baseLayout 行业切换 ([c0f6d3f](https://g.civnet.cn:8443/test/maintenance/commits/c0f6d3f5ae3094ce1e5613814e269b8bbc293870))
* 修复baseLayout 行业切换 ([980e8e9](https://g.civnet.cn:8443/test/maintenance/commits/980e8e9ab609058bf019aecdf3b76971a29ea82d))
* 修复baseLayout 行业切换 ([bfd1459](https://g.civnet.cn:8443/test/maintenance/commits/bfd1459fb5b97636bfb7b4f6649d841f31e946ef))
* 修复loading 加载时机 ([0e8f691](https://g.civnet.cn:8443/test/maintenance/commits/0e8f6915ac6e5dc6a04d3511197675755ca3bc00))
* 修复url-loader打包视频路径问题 ([f402391](https://g.civnet.cn:8443/test/maintenance/commits/f4023914143e41bc800808b022383bff2ebea065))
* 修复左侧菜单栏初始化配置 ([034210f](https://g.civnet.cn:8443/test/maintenance/commits/034210fe917f9b3386e4d9c414bd47ff01d5b8b8))
* 修复菜单切换 ([153bb20](https://g.civnet.cn:8443/test/maintenance/commits/153bb209a5e587a196bba34df0c2f224d59845b1))
* 修改快捷键跳转到运维路径 ([eddbeca](https://g.civnet.cn:8443/test/maintenance/commits/eddbeca5c667f76702312d132e472fadb04042bd))
* 修改静态资源问题 ([76b86c7](https://g.civnet.cn:8443/test/maintenance/commits/76b86c75e5f7323ec8ee8053ce51a79a57a14ee9))
* 去除debugger ([c7e7625](https://g.civnet.cn:8443/test/maintenance/commits/c7e7625cde2e697cd991d6336c17aac5a0f54c4f))
* 去除debugger ([99f81a2](https://g.civnet.cn:8443/test/maintenance/commits/99f81a2bd693ff55100ef11e6823e61d8bb7d034))
### Features
* add avatar upload ([5e11941](https://g.civnet.cn:8443/test/maintenance/commits/5e11941346ae16dc3c301bf13ccc00a1e4edd05d))
* add avatar upload ([279b992](https://g.civnet.cn:8443/test/maintenance/commits/279b9923c348ef5ff035dab48243ba37cc122094))
* add mockMiddlewares ([3093a11](https://g.civnet.cn:8443/test/maintenance/commits/3093a118cc8e1219f7fbc2dde31ee44d364ca66a))
* add pages/transitionalpagee ([40be263](https://g.civnet.cn:8443/test/maintenance/commits/40be26355fab5461f698af027a1018d285c73b97))
* add systemMessage push ([2e9397b](https://g.civnet.cn:8443/test/maintenance/commits/2e9397bd91a2085cb4f4fa5dc8b3f43a8d5a8ba1))
* add web.config ([6246d3d](https://g.civnet.cn:8443/test/maintenance/commits/6246d3d882049be059576495c5f2c0b908306788))
* ci add lint checkout workflow ([587e179](https://g.civnet.cn:8443/test/maintenance/commits/587e1793b2e6c8bab6f3be1e7cb875a984e61873))
* message add title ([13b2d66](https://g.civnet.cn:8443/test/maintenance/commits/13b2d66a4d841eb256a13823f3cfa4352d6f8170))
* update kit_global_config ([9e4b4c6](https://g.civnet.cn:8443/test/maintenance/commits/9e4b4c6d2914e39f8f5a6c70534b3d904b365ba5))
* update kit_global_config ([e18c969](https://g.civnet.cn:8443/test/maintenance/commits/e18c969d9f8613860776c7b6fa28b100f8b165e7))
* update package.json ([c5dba39](https://g.civnet.cn:8443/test/maintenance/commits/c5dba39608cbae89ddedaa2612e79355e436d626))
* 优化消息 ([85d9918](https://g.civnet.cn:8443/test/maintenance/commits/85d99182ac01c55116ac49352d79b09d96fbd67a))
* 优化菜单加载速度 ([ef0aa0e](https://g.civnet.cn:8443/test/maintenance/commits/ef0aa0e8a4083c1fd49dac80aff0d6b52669e544))
* 修改defaultSetting.js默认配置 ([3539126](https://g.civnet.cn:8443/test/maintenance/commits/35391263e1add7f7a3d5e2f950659ca3f29daee8))
* 新增多标签模式 ([51c5066](https://g.civnet.cn:8443/test/maintenance/commits/51c50661dfe80f5b9e092d4bd959fb3c368082fa))
* 菜单搜索添加键盘选择事件 ([f50f9f3](https://g.civnet.cn:8443/test/maintenance/commits/f50f9f3f64fce9a048aab39a1da4f55fceeffa4b))
### Performance Improvements
* delete console.log ([c2a85c3](https://g.civnet.cn:8443/test/maintenance/commits/c2a85c3f1fe92a26763ad31f9ab4a1b8339b88c8))
* updrage request http ([5bcdf47](https://g.civnet.cn:8443/test/maintenance/commits/5bcdf471af33667062be0bab96f6fd1605efbe7a))
* 优化layout ([0fe6cea](https://g.civnet.cn:8443/test/maintenance/commits/0fe6ceae5037a002d3f72bc1cd2e5371ca310e93))
* 优化layout ([c6eb43f](https://g.civnet.cn:8443/test/maintenance/commits/c6eb43f46b95b6c55d32b747fe4a64a6f0aea1b9))
* 优化引导页 ([eea4acc](https://g.civnet.cn:8443/test/maintenance/commits/eea4acc818a9ad66162ac32733e2c3a3fb500f2b))
* 优化引导页 ([5e26a60](https://g.civnet.cn:8443/test/maintenance/commits/5e26a609bb1abd2fa5379a37a6205c47b3e4f556))
* 优化菜单加载 ([aa76b29](https://g.civnet.cn:8443/test/maintenance/commits/aa76b29c6ae4158a8024e28d6bab22f613855189))
## [0.0.20](https://g.civnet.cn:8443/test/maintenance/compare/v0.0.19...v0.0.20) (2020-12-25)
......
module.exports = {
presets: [
[
'@babel/preset-env',
{
modules: false,
},
],
'@babel/preset-react',
],
plugins: [
'styled-components',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
['import', { libraryName: 'antd', style: true }],
],
env: {
production: {
only: ['src'],
plugins: [
'lodash',
'transform-react-remove-prop-types',
'@babel/plugin-transform-react-inline-elements',
'@babel/plugin-transform-react-constant-elements',
],
},
test: {
plugins: [
'@babel/plugin-transform-modules-commonjs',
'dynamic-import-node',
],
},
},
};
const { join } = require('path');
const proxy = require('./proxy');
const slash = require('slash2');
const defaultSetting = require('./defaultSetting');
function resolve (dir) {
return join(__dirname, '../', dir)
}
const { REACT_APP_ENV } = process.env;
module.exports = {
title: '熊猫智慧城市监控管理解决方案',
hash: true,
layout: {
siderWidth: '145px',
locale: true,
...defaultSetting
},
fastRefresh: true,
locale: {
default: 'zh-CN',
antd: true,
baseNavigator: true,
},
dynamicImport: {
loading: '@ant-design/pro-layout/es/PageLoading',
},
// theme: {
// '@primary-color': '#ff9600',
// },
ignoreMomentLocale: true,
nodeModulesTransform: {
type: 'none',
exclude: [],
},
proxy: proxy[REACT_APP_ENV || 'dev'],
openAPI: {
requestLibPath: "import { request } from '@wisdom-utils/utils'",
schemaPath: 'http://192.168.10.150:8777/Publish/OMS/swagger/v1/swagger.json',
mock: false,
},
postcssLoader: {},
styleLoader: {},
cssLoader: {
modules: {
getLocalIdent: (context, _, localName) => {
if (
context.resourcePath.includes('node_modules') ||
context.resourcePath.includes('ant.design.pro.less') ||
context.resourcePath.includes('global.less')
) {
return localName;
}
const match = context.resourcePath.match(/src(.*)/);
if (match && match[1]) {
const antdProPath = match[1].replace('.less', '');
const arr = slash(antdProPath)
.split('/')
.map(a => a.replace(/([A-Z])/g, '-$1'))
.map(a => a.toLowerCase());
return `panda-pro${arr.join('-')}-${localName}`.replace(
/--/g,
'-',
);
}
return localName;
},
},
},
};
export default {
module.exports = {
navTheme: 'dark',
layout: 'side',
contentWidth: 'Fluid',
......
......@@ -10,12 +10,12 @@ export default {
activeRule: genActiveRule('/civbase/civweb4'),
props: {},
},
// {
// name: 'civweb5',
// entry: `//${window.location.hostname}:3002/civbase/civweb5`,
// container: '#micro-container',
// activeRule: genActiveRule('/civbase/civweb5'),
// },
{
name: 'civmanage',
entry: `//${window.location.hostname}:8081/civbase/civmanage`,
container: '#micro-container',
activeRule: genActiveRule('/civbase/civmanage'),
},
],
prod: [
{
......
const ThemeColorReplacer = require('webpack-theme-color-replacer');
const generate = require('@ant-design/colors');
const getAntdSerials = color => {
// 淡化(即less的tint)
const lightens = new Array(9)
.fill()
.map((t, i) => ThemeColorReplacer.varyColor.lighten(color, i / 10));
const colorPalettes = generate.generate(color);
const rgb = ThemeColorReplacer.varyColor
.toNum3(color.replace('#', ''))
.join(',');
return lightens.concat(colorPalettes).concat(rgb);
};
const themePluginOption = {
fileName: 'css/theme-colors-[contenthash:8].css',
matchColors: getAntdSerials('#1890ff'), // 主色系列
// 改变样式选择器,解决样式覆盖问题
changeSelector(selector) {
switch (selector) {
case '.ant-calendar-today .ant-calendar-date':
return `:not(.ant-calendar-selected-date):not(.ant-calendar-selected-day)${selector}`;
case '.ant-btn:focus,.ant-btn:hover':
return '.ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger),.ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger)';
case '.ant-btn.active,.ant-btn:active':
return '.ant-btn.active:not(.ant-btn-primary):not(.ant-btn-danger),.ant-btn:active:not(.ant-btn-primary):not(.ant-btn-danger)';
case '.ant-steps-item-process .ant-steps-item-icon > .ant-steps-icon':
case '.ant-steps-item-process .ant-steps-item-icon>.ant-steps-icon':
return `:not(.ant-steps-item-process)${selector}`;
// fixed https://github.com/vueComponent/ant-design-vue-pro/issues/876
case '.ant-steps-item-process .ant-steps-item-icon':
return `:not(.ant-steps-item-custom)${selector}`;
case '.ant-menu-horizontal>.ant-menu-item-active,.ant-menu-horizontal>.ant-menu-item-open,.ant-menu-horizontal>.ant-menu-item-selected,.ant-menu-horizontal>.ant-menu-item:hover,.ant-menu-horizontal>.ant-menu-submenu-active,.ant-menu-horizontal>.ant-menu-submenu-open,.ant-menu-horizontal>.ant-menu-submenu-selected,.ant-menu-horizontal>.ant-menu-submenu:hover':
case '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal > .ant-menu-submenu-selected,.ant-menu-horizontal > .ant-menu-submenu:hover':
return '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu-selected,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu:hover';
case '.ant-menu-horizontal > .ant-menu-item-selected > a':
case '.ant-menu-horizontal>.ant-menu-item-selected>a':
return '.ant-menu-horizontal:not(ant-menu-light):not(.ant-menu-dark) > .ant-menu-item-selected > a';
case '.ant-menu-horizontal > .ant-menu-item > a:hover':
case '.ant-menu-horizontal>.ant-menu-item>a:hover':
return '.ant-menu-horizontal:not(ant-menu-light):not(.ant-menu-dark) > .ant-menu-item > a:hover';
default:
return selector;
}
},
};
// const createThemeColorReplacerPlugin = () =>
// new ThemeColorReplacer(themePluginOption);
module.exports = {
ThemeColorReplacer,
themePluginOption
};
/* eslint-disable */
// const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin;
const proxyURL = 'https://panda-water.cn';
const proxyURL = 'http://192.168.10.150:8777';
module.exports = {
mock: true,
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : window.location.origin,
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './',
dev: {
'/CityInterface': {
target: proxyURL,
......@@ -82,7 +81,7 @@ module.exports = {
},
},
},
prod: {
pre: {
'/CityInterface': {
target: 'https://panda-water.cn',
changeOrigin: true,
......
---
title: 基础组件
nav:
title: 组件
order: 1
---
\ No newline at end of file
---
title: 常见问题
nav:
title: faq
order: 3
---
\ No newline at end of file
---
title: script 命令
nav:
title: 指南
order: 1
---
# script 命令
## 初始化
```Shell
npm run setup
```
初始化一个新项目, 安装依赖项并初始化
## 开发环境
```Shell
npm run start
```
Starts the development server running on `http://localhost:3000`
## 清除
```Shell
npm run clean
```
删除应用代码,开始编写新的应用代码
## 生成模版代码块
```Shell
npm run generate
```
允许自动生成通用代码的样板代码应用, `component`, `container`<br>
执行 `npm run generate <part>`, 选择
## 服务
### 开发环境
```Shell
npm start
```
Starts the development server running on http://localhost:3000. 代码中的更改将被热加载.
### 生产环境
```Shell
npm run start:production
```
- 执行自动化测试脚本 (see `npm test`)
- 执行打包脚本 (see `npm run build`)
- 执行生产环境打包 (see `npm run start:prod`)
### Host and Port
更改ip或端口访问, 通过参数 `--host``--port` 命令行参数<br>
`npm start -- --host 127.0.0.1 --port 5000`
## 打包
```Shell
npm run build
```
## Testing
See the [testing documentation](../testing/README.md) for detailed information
about our testing setup!
## 单元测试
```Shell
npm test
```
### Watching
```Shell
npm run test:watch
```
## 检查代码规范
```Shell
npm run lint
```
```Shell
npm run lint:eslint:fix -- .
```
\ No newline at end of file
---
title: 快速上手
order: 9
nav:
order: 10
---
## 环境准备
首先得有 [node](https://nodejs.org/en/),并确保 node 版本是 10.13 或以上。
```bash
$ node -v
v10.13.0
```
## 脚手架初始化
---
title: 介绍
nav:
title: 指南
order: 1
---
### 技术栈
这是一个基本软件包列表,在您开始初始化项目之前,至少熟悉这些依赖包。 但是,查看依赖项完整列表的最佳方法是检查package.json
### Core
- [ ] [React](https://facebook.github.io/react/)
- [ ] [React Router](https://github.com/ReactTraining/react-router)
- [ ] [Redux](http://redux.js.org/)
- [ ] [redux-thunk](https://redux-saga.github.io/redux-saga/)
- [ ] [Reselect](https://github.com/reactjs/reselect)
- [ ] [Immutable](https://github.com/immutable-js/immutable-js)
- [ ] [React Hooks](https://github.com/alibaba/hooks.git)
### UI
- [ ] [Ant-Design](https://github.com/ant-design/ant-design)
- [ ] [pro-components](https://github.com/ant-design/pro-components)
### Unit Testing
- [ ] [Jest](http://facebook.github.io/jest/)
- [ ] [react-testing-library](https://github.com/kentcdodds/react-testing-library)
### Linting
- [ ] [ESLint](http://eslint.org/)
- [ ] [Prettier](https://prettier.io/)
- [ ] [stylelint](https://stylelint.io/)
### commitlint
- [ ] [commitlint+husky](https://github.com/conventional-changelog/commitlint)
## 项目结构
- docs
- internals
- server
- src
- components
- containers
- layouts
- pages
- routes
- utils
\ No newline at end of file
---
title: 运维平台 - 开发文档
order: 10
hero:
title: 运维平台
actions:
- text: 快速开始
link: /guide/getting-started
footer: Open-source MIT Licensed | Copyright © 2020-present<br />Powered by self
---
<br>
## 快速开始
```bash
// 拉取代码
$ git clone https://g.civnet.cn:8443/test/maintenance.git
// 安装
$ npm run setup
// 启动
$ npm start
```
......@@ -19,8 +19,8 @@ import { DEFAULT_LOCALE } from '../../../i18n';
describe('
<{{ properCase name }} />', () => {
it('Expect to not log errors in console', () => {
const spy = jest.spyOn(global.console, 'error');
it('Expect to not log errors in console', () => {
const spy = jest.spyOn(global.console, 'error');
{{#if wantMessages}}
render(
<IntlProvider locale={DEFAULT_LOCALE}>
......@@ -31,11 +31,11 @@ render(
render(
<{{ properCase name }} />);
{{/if}}
expect(spy).not.toHaveBeenCalled();
expect(spy).not.toHaveBeenCalled();
});
it('Expect to have additional unit tests specified', () => {
expect(true).toEqual(false);
expect(true).toEqual(false);
});
/**
......@@ -45,19 +45,14 @@ expect(true).toEqual(false);
*/
it.skip('Should render and match the snapshot', () => {
{{#if wantMessages}}
const {
container: { firstChild },
} = render(
<IntlProvider locale={DEFAULT_LOCALE}>
<{{ properCase name }} />
</IntlProvider>,
);
const { container: { firstChild },} = render(
<IntlProvider locale={DEFAULT_LOCALE}>
<{{ properCase name }} />
</IntlProvider>,);
{{else}}
const {
container: { firstChild },
} = render(
<{{ properCase name }} />);
const { container: { firstChild }, } = render(
<{{ properCase name }} />);
{{/if}}
expect(firstChild).toMatchSnapshot();
});
expect(firstChild).toMatchSnapshot();
});
});
\ No newline at end of file
"use strict";
var _require = require('child_process'),
spawn = _require.spawn;
var spawnWin = require('cross-spawn');
module.exports = function exec(command, args, opts) {
return new Promise(function (resolve, reject) {
var child = process.platform === 'win32' ? spawnWin(command, args, Object.assign({
stdio: 'inherit',
env: process.env
}, opts)) : spawn(command, args, Object.assign({
stdio: 'inherit',
env: process.env
}, opts));
child.once('error', function (err) {
console.log(err);
reject(err);
});
child.once('close', function (code) {
if (code === 1) {
process.exit(1);
} else {
resolve();
}
});
});
};
\ No newline at end of file
"use strict";
module.exports = function (version) {
return version.includes('-rc.') || version.includes('-beta.') || version.includes('-alpha.');
};
\ No newline at end of file
const { mergeConfig } = require('@umijs/utils');
const { dirname } = require('path');
function toObject(obj) {
return typeof obj === 'object' ? obj : {};
}
module.exports = opts => {
const defaultEnvConfig = {
exclude: [
'transform-typeof-symbol',
'transform-unicode-regex',
'transform-sticky-regex',
'transform-new-target',
'transform-modules-umd',
'transform-modules-systemjs',
'transform-modules-amd',
'transform-literals',
],
};
const preset = {
presets: [
opts.env && [
'@babel/preset-env',
{
...mergeConfig(defaultEnvConfig,{}),
modules: false
},
],
opts.react && ['@babel/preset-react'],
opts.typescript && [
'@babel/preset-typescript',
{
allowNamespaces: true,
},
],
].filter(Boolean),
plugins: [
['@babel/plugin-proposal-optional-chaining', { loose: false }],
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: false }],
'@babel/plugin-syntax-top-level-await',
['@babel/plugin-transform-destructuring', { loose: false }],
opts.typescript && ['babel-plugin-transform-typescript-metadata'],
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-transform-flow-strip-types',
'@babel/plugin-proposal-export-default-from',
[
'@babel/plugin-proposal-pipeline-operator',
{
proposal: 'minimal',
},
],
'@babel/plugin-proposal-do-expressions',
'@babel/plugin-proposal-function-bind',
'@babel/plugin-proposal-logical-assignment-operators',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-transform-react-jsx',
// opts.transformRuntime && [
// '@babel/plugin-transform-runtime',
// {
// version: require('@babel/runtime/package.json').version,
// absoluteRuntime: dirname(
// require.resolve('@babel/runtime/package.json'),
// ),
// useESModules: true,
// ...toObject(opts.transformRuntime),
// },
// ],
[
'babel-plugin-transform-react-remove-prop-types',
{
removeImport: true,
},
],
opts.reactRequire && ['babel-plugin-react-require'],
opts.dynamicImportNode && ['babel-plugin-dynamic-import-node'],
opts.autoCSSModules && ['@umijs/babel-plugin-auto-css-modules'],
opts.svgr && [
'babel-plugin-named-asset-import',
{
loaderMap: {
svg: {
ReactComponent: `${require.resolve(
'@svgr/webpack',
)}?-svgo,+titleProp,+ref![path]`,
},
},
},
],
...(opts.import
? opts.import.map(importOpts => {
return ['babel-plugin-import', importOpts, importOpts.libraryName];
})
: []),
opts.importToAwaitRequire && [
'@umijs/babel-plugin-import-to-await-require',
opts.importToAwaitRequire,
],
// opts.lockCoreJS3 && [
// '@umijs/babel-plugin-lock-core-js-3',
// opts.lockCoreJS3,
// ],
].filter(Boolean),
env: {
production: {
only: ['src'],
plugins: [
'lodash',
'transform-react-remove-prop-types',
'@babel/plugin-transform-react-inline-elements',
'@babel/plugin-transform-react-constant-elements',
],
},
development: {
plugins: ['react-refresh/babel'],
},
test: {
plugins: [
'@babel/plugin-transform-modules-commonjs',
'dynamic-import-node',
],
},
},
};
return opts.modify ? opts.modify(preset) : preset;
};
......@@ -8,6 +8,7 @@ const pkg = require('../../package.json');
const webpackConfig = require('./webpack.prod.babel')
const argv = require('../../server/argv');
const spinner = ora('building for production...');
const { printFileSizes } = require('./buildDevUtil');
// const Diff = require('diff');
/* eslint-disable */
spinner.start()
......@@ -24,15 +25,16 @@ rm(
webpack(webpackConfig, function (err, stats) {
spinner.stop()
if (err) throw err
process.stdout.write(`${stats.toString({
colors: true,
color: true,
progress: true,
modules: false,
children: false,
chunks: true,
chunkModules: true
}) }\n\n`)
// process.stdout.write(`${stats.toString({
// colors: true,
// color: true,
// progress: true,
// modules: false,
// children: false,
// chunks: true,
// chunkModules: true
// }) }\n\n`)
printFileSizes(stats, path.relative(process.cwd(), webpackConfig.output.path));
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
......
const { rimraf, chalk } = require('@umijs/utils');
const path = require('path');
const zlib = require('zlib');
const fs = require('fs');
const WARN_AFTER_BUNDLE_GZIP_SIZE = 1.8 * 1024 * 1024;
const WARN_AFTER_CHUNK_GZIP_SIZE = 1 * 1024 * 1024;
function printFileSizes(stats, dir) {
const ui = require('cliui')({ width: 120 });
const json = stats.toJson({
hash: false,
modules: false,
chunks: false,
});
const filesize = bytes => {
bytes = Math.abs(bytes);
const radix = 1024;
const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
let loop = 0;
// calculate
while (bytes >= radix) {
bytes /= radix;
++loop;
}
return `${bytes.toFixed(1)} ${unit[loop]}`;
};
const assets = json.assets
? json.assets
: json && json.children.reduce((acc, child) => acc.concat(child.assets), []);
const seenNames = new Map();
const isJS = val => /\.js$/.test(val);
const isCSS = val => /\.css$/.test(val);
const orderedAssets =
assets &&
assets
.map(a => {
a.name = a.name.split('?')[0];
const isMainBundle = a.name.indexOf('main.') === 0;
const maxRecommendedSize = isMainBundle
? WARN_AFTER_BUNDLE_GZIP_SIZE
: WARN_AFTER_CHUNK_GZIP_SIZE;
const isLarge = maxRecommendedSize && a.size > maxRecommendedSize;
return {
...a,
suggested: isLarge && isJS(a.name),
};
})
.filter(a => {
if (seenNames.has(a.name)) {
return false;
}
seenNames.set(a.name, true);
return isJS(a.name) || isCSS(a.name);
})
.sort((a, b) => {
if (isJS(a.name) && isCSS(b.name)) return -1;
if (isCSS(a.name) && isJS(b.name)) return 1;
return b.size - a.size;
});
function getGzippedSize(asset) {
const filepath = path.resolve(path.join(dir, asset.name));
if (fs.existsSync(filepath)) {
const buffer = fs.readFileSync(filepath);
return filesize(zlib.gzipSync(buffer).length);
}
return filesize(0);
}
function makeRow(a, b, c) {
return ` ${a}\t ${b}\t ${c}`;
}
ui.div(
makeRow(
chalk.cyan.bold(`File`),
chalk.cyan.bold(`Size`),
chalk.cyan.bold(`Gzipped`),
) +
`\n\n` +
orderedAssets && orderedAssets .map(asset =>
makeRow(
/js$/.test(asset.name)
? asset.suggested
?
chalk.yellow(path.join(dir, asset.name))
: chalk.green(path.join(dir, asset.name))
: chalk.blue(path.join(dir, asset.name)),
filesize(asset.size),
getGzippedSize(asset),
),
)
.join(`\n`),
);
console.log(
`${ui.toString()}\n\n ${chalk.gray(
`Images and other types of assets omitted.`,
)}\n`,
);
if (orderedAssets && orderedAssets.some((asset) => asset.suggested)) {
// We'll warn for bundles exceeding them.
console.log();
console.log(
chalk.yellow('The bundle size is significantly larger than recommended.'),
);
console.log(
chalk.yellow(
'You can also analyze the project dependencies using ANALYZE=1',
),
);
console.log();
}
}
module.exports = {
printFileSizes
}
\ No newline at end of file
const { deepmerge } = require('@umijs/utils');
const safePostCssParser = require('postcss-safe-parser');
const BundlerConfigType = {
csr:'csr',
ssr:'ssr',
}
function createCSSRule({
webpackConfig,
type,
config,
lang,
test,
isDev,
loader,
options,
browserslist,
miniCSSExtractPluginLoaderPath,
}) {
const rule = webpackConfig.module.rule(lang).test(test);
applyLoaders(rule.oneOf('css-modules').resourceQuery(/modules/), true);
applyLoaders(rule.oneOf('css'), false);
applyLoaders(rule.oneOf('less'), true);
function applyLoaders(rule, isCSSModules) {
if(config.styleLoader) {
rule
.use('style-loader')
.loader(require.resolve('style-loader'))
.options(
deepmerge(
{
base: 0,
},
config.styleLoader,
),
);
} else {
if (!config.styleLoader) {
rule
.use('extract-css-loader')
.loader(
require('mini-css-extract-plugin').loader,
)
.options({
publicPath: './',
hmr: isDev,
});
}
}
if(isDev && isCSSModules && config.cssModulesTypescriptLoader) {
rule
.use('css-modules-typescript-loader')
.loader(require.resolve('css-modules-typescript-loader'))
.options(config.cssModulesTypescriptLoader)
}
rule
.use('css-loader')
.loader(require.resolve('css-loader'))
.options(
deepmerge(
{
importLoaders: 1,
...(isCSSModules
? {
modules: config.cssLoader.modules,
}
: {}),
},
config.cssLoader || {},
),
);
rule
.use('postcss-loader')
.loader(require.resolve('postcss-loader'))
.options(
deepmerge(
{
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
require('postcss-preset-env')({
// TODO: set browsers
autoprefixer: {
...config.autoprefixer,
overrideBrowserslist: browserslist,
},
// https://cssdb.org/
stage: 3,
}),
...(config.extraPostCSSPlugins ? config.extraPostCSSPlugins : []),
],
},
config.postcssLoader || {},
),
);
if (loader) {
rule
.use(loader)
.loader(require.resolve(loader))
.options(options || {});
}
}
};
function css({
type,
config,
webpackConfig,
isDev,
disableCompress,
browserslist,
miniCSSExtractPluginPath,
miniCSSExtractPluginLoaderPath,
}) {
createCSSRule({
type,
webpackConfig,
config,
isDev,
lang: 'css',
test: /\.(css)(\?.*)?$/,
browserslist,
miniCSSExtractPluginLoaderPath,
});
const theme = config.theme;
createCSSRule({
type,
webpackConfig,
config,
isDev,
lang: 'less',
test: /\.(less)(\?.*)?$/,
loader: 'less-loader',
options: deepmerge(
{
modifyVars: theme,
javascriptEnabled: true,
},
config.lessLoader || {},
),
browserslist,
miniCSSExtractPluginLoaderPath,
});
if(!config.styleLoader) {
const hash = !isDev && config.hash ? '.[contenthash:8]' : '';
webpackConfig
.plugin('extract-css')
.use(
require('mini-css-extract-plugin'),
[
{
filename: `[name]${hash}.css`,
chunkFilename: `[name]${hash}.chunk.css`,
ignoreOrder: true,
},
]
)
}
if (!isDev && !disableCompress) {
webpackConfig
.plugin('optimize-css')
.use(require.resolve('optimize-css-assets-webpack-plugin'), [
{
cssProcessorOptions: {
parser: safePostCssParser,
},
cssProcessorPluginOptions: {
preset: ['default', config.cssnano],
},
},
]);
}
if(config.sass) {
createCSSRule({
lang: 'sass',
test: /\.(sass|scss)(\?.*)?$/,
loader: require.resolve('sass-loader'),
options: utils.deepmerge(
{
implementation: require('sass'),
},
config.sass || {},
),
})
}
}
module.exports = {
createCSSRule,
css
}
\ No newline at end of file
const { dirname } = require('path');
const {
pkgUp,
semver,
} = require('@umijs/utils');
const pkgPathCache = {};
const pkgCache = {};
// type 为 all 时以下依赖不走 babel 编译
const TYPE_ALL_EXCLUDE = [
'@ant-design/icons',
'@ant-design/icons-svg',
'@babel/runtime',
'core-js',
'echarts',
'lodash',
'react',
'react-dom',
];
// 参考:
// https://github.com/umijs/umi/blob/2.x/packages/af-webpack/src/getWebpackConfig/es5ImcompatibleVersions.js
function isMatch(opts) {
const pkgPath = getPkgPath(opts);
// 可能没有 package.json
if (!pkgPath) return false;
if (pkgPath in pkgCache) return pkgCache[pkgPath];
const { name, version } = require(pkgPath); // eslint-disable-line
if (opts.pkgs[name]) {
pkgCache[pkgPath] = opts.pkgs[name].some((v) => {
return semver.satisfies(version, v);
});
} else {
pkgCache[pkgPath] = false;
}
return pkgCache[pkgPath];
}
function getPkgPath(opts) {
const dir = dirname(opts.path);
if (dir in pkgPathCache) return pkgPathCache[dir];
pkgPathCache[dir] = pkgUp.sync({ cwd: opts.path });
return pkgPathCache[dir];
}
function excludeToPkgs(opts) {
return opts.exclude.reduce((memo, exclude) => {
const { name, versions } = excludeToPkg({ exclude });
memo[name] = versions;
return memo;
}, {});
}
function excludeToPkg(opts) {
let firstAt = '';
let left = opts.exclude;
if (left.charAt(0) === '@') {
firstAt = '@';
left = left.slice(1);
}
let [name, version] = left.split('@');
name = `${firstAt}${name}`;
if (!version) {
version = '*';
}
return { name, versions: [version] };
}
function es5ImcompatibleVersionsToPkg() {
const {
config: { 'es5-imcompatible-versions': config },
} = require('es5-imcompatible-versions/package.json');
return Object.keys(config).reduce((memo, key) => {
memo[key] = Object.keys(config[key]);
return memo;
}, {});
}
module.exports = {
TYPE_ALL_EXCLUDE,
isMatch,
getPkgPath,
excludeToPkg,
excludeToPkgs,
es5ImcompatibleVersionsToPkg
}
\ No newline at end of file
const { dirname } = require('path');
const { pkgUp } = require('@umijs/utils');
const pkgPathCache = {};
function getPkgPath(filePath) {
const dir = dirname(filePath);
if (dir in pkgPathCache) return pkgPathCache[dir];
pkgPathCache[dir] = pkgUp.sync({ cwd: filePath });
return pkgPathCache[dir];
}
function shouldTransform(pkgPath, include) {
const { name } = require(pkgPath);
return name === include;
}
module.exports = {
getPkgPath,
shouldTransform
}
\ No newline at end of file
const { chalk, clipboardy, address } = require('@umijs/utils');
class DevCompileDonePlugin {
constructor(opts) {
this.opts = opts;
}
apply(compiler) {
let isFirstCompile = true;
compiler.hooks.done.tap('DevFirstCompileDone', stats => {
if (stats.hasErrors()) {
// make sound
if (process.env.SYSTEM_BELL !== 'none') {
process.stdout.write('\x07');
}
this.opts.onCompileFail && this.opts.onCompileFail({
stats,
});
return;
}
if (isFirstCompile) {
const lanIp = address.ip();
const protocol = this.opts.https ? 'https' : 'http';
const hostname =
this.opts.hostname === '0.0.0.0' ? 'localhost' : this.opts.hostname;
const localUrl = `${protocol}://${hostname}:${this.opts.port}`;
const lanUrl = `${protocol}://${lanIp}:${this.opts.port}`;
let copied = '';
try {
clipboardy.writeSync(localUrl);
copied = chalk.dim('(copied to clipboard)');
} catch (e) {
copied = chalk.red(`(copy to clipboard failed)`);
}
console.log();
console.log(
[
` App running at:`,
` - Local: ${chalk.cyan(localUrl)} ${copied}`,
lanUrl && ` - Network: ${chalk.cyan(lanUrl)}`,
]
.filter(Boolean)
.join('\n'),
);
}
this.opts.onCompileDone && this.opts.onCompileDone({
isFirstCompile,
stats,
});
if(isFirstCompile) {
isFirstCompile = false;
// process.send({
// type: 'DONE'
// })
}
});
}
}
module.exports = DevCompileDonePlugin;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { cheerio } = require('@umijs/utils');
class MyPlugin {
constructor(opts) {
this.opts = opts;
}
getAsset(opts) {
if (/^(https|http)?:\/\//.test(opts.file)) {
return opts.file;
}
// const file = opts.file.charAt(0) === '/' ? opts.file.slice(1) : opts.file;
// return `${this.config.publicPath}${file}`;
}
getStyles(option) {
const linkArr = [];
const styleObj = [];
if (Array.isArray(option) && option.length > 0) {
option.forEach(style => {
if (typeof style === 'string') {
if (EXP_URL.test(style)) {
// is <link />
linkArr.push({
charset: 'utf-8',
rel: 'stylesheet',
type: 'text/css',
href: style,
});
} else {
styleObj.push({
content: style,
});
}
}
if (typeof style === 'object') {
// is style object
styleObj.push(style);
}
});
}
return [linkArr, styleObj];
}
getScriptsContent(scripts) {
return scripts
.map(script => {
const { content, ...attrs } = script;
if (content && !attrs.src) {
const newAttrs = Object.keys(attrs).reduce((memo, key) => {
return [...memo, `${key}="${attrs[key]}"`];
}, []);
return [
`<script${newAttrs.length ? ' ' : ''}${newAttrs.join(' ')}>`,
content
.split('\n')
.map(line => ` ${line}`)
.join('\n'),
'</script>',
].join('\n');
} else {
const newAttrs = Object.keys(attrs).reduce((memo, key) => {
return [...memo, `${key}="${attrs[key]}"`];
}, []);
return `<script ${newAttrs.join(' ')}></script>`;
}
})
.join('\n');
}
getContent(html, config) {
let {
metas = [],
links = [],
headScripts = [],
scripts = [],
} = config;
const $ = cheerio.load(html, {
decodeEntities: false,
});
metas.forEach(meta => {
$('head').append(
[
'<meta',
...Object.keys(meta).reduce((memo, key) => {
return memo.concat(`${key}="${meta[key]}"`);
}, []),
'/>',
].join(' '),
);
});
links.forEach(link => {
$('head').append(
[
'<link',
...Object.keys(link).reduce((memo, key) => {
return memo.concat(`${key}="${link[key]}"`);
}, []),
'/>',
].join(' '),
);
});
const [linkArr = [], styleArr = []] = this.getStyles(this.opts.config.styles);
styleArr.forEach(style => {
const { content = '', ...attrs } = style;
const newAttrs = Object.keys(attrs).reduce((memo, key) => {
return memo.concat(`${key}="${attrs[key]}"`);
}, []);
$('head').append(
[
`<style${newAttrs.length ? ' ' : ''}${newAttrs.join(' ')}>`,
content
.split('\n')
.map(line => ` ${line}`)
.join('\n'),
'</style>',
].join('\n'),
);
});
if (headScripts.length) {
$('head').append(this.getScriptsContent(headScripts));
}
if (scripts.length) {
$('body').append(this.getScriptsContent(scripts));
}
linkArr.forEach(file => {
$('head').append(
`<link rel="stylesheet" href="${this.getAsset({
file: file.href,
})}" />`,
);
});
html = $.html();
return html;
}
apply(compiler) {
compiler.hooks.compilation.tap('MyPlugin', compilation => {
HtmlWebpackPlugin.getHooks(compilation).afterTemplateExecution.tapAsync(
'MyPlugin', // <-- Set a meaningful name here for stacktraces
(data, cb) => {
if (data && data.html !== '') {
data.html = this.getContent(data.html, this.opts.config);
}
// Tell webpack to move on
cb(null, data);
},
);
});
}
}
module.exports = MyPlugin;
const prefixRE = /^CIV_APP_/;
const ENV_SHOULD_PASS = ['NODE_ENV', 'HMR', 'SOCKET_SERVER', 'ERROR_OVERLAY'];
module.exports = (opts) => {
const env = {};
Object.keys(process.env).forEach((key) => {
if (prefixRE.test(key) || ENV_SHOULD_PASS.includes(key)) {
env[key] = process.env[key];
}
});
for (const key in env) {
env[key] = JSON.stringify(env[key]);
}
const define = {};
if (opts.define) {
for (const key in opts.define) {
define[key] = JSON.stringify(opts.define[key]);
}
}
return {
'process.env': env,
...define,
};
}
\ No newline at end of file
__webpack_public_path__ = window.publicPath;
\ No newline at end of file
module.exports = {
parse: {
ecma: 8,
},
compress: {
ecma: 5,
warnings: false,
// turn off flags with small gains to speed up minification
arrows: false,
collapse_vars: false, // 0.3kb
comparisons: false,
computed_props: false,
hoist_funs: false,
hoist_props: false,
hoist_vars: false,
inline: false,
loops: false,
negate_iife: false,
properties: false,
reduce_funcs: false,
reduce_vars: false,
switches: false,
toplevel: false,
typeofs: false,
// a few flags with noticable gains/speed ratio
// numbers based on out of the box vendor bundle
booleans: true, // 0.7kb
if_return: true, // 0.4kb
sequences: true, // 0.7kb
unused: true, // 2.3kb
// required features to drop conditional branches
conditionals: true,
dead_code: true,
evaluate: true,
},
mangle: {
safari10: true,
},
output: {
ecma: 5,
comments: false,
ascii_only: true,
},
};
This diff is collapsed.
......@@ -3,10 +3,7 @@
*/
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
module.exports = require('./webpack.base.babel')({
mode: 'development',
......@@ -16,29 +13,18 @@ module.exports = require('./webpack.base.babel')({
'webpack-hot-middleware/client?reload=true',
path.join(process.cwd(), 'src/app.js'), // Start with js/app.js
],
// Don't use hashes in dev mode for better performance
output: {
filename: '[name].js',
chunkFilename: '[name].chunk.js',
},
optimization: {
splitChunks: {
chunks: 'all',
},
},
// Add development plugins
plugins: [
new webpack.HotModuleReplacementPlugin(), // Tell webpack we want hot reloading
new HtmlWebpackPlugin({
inject: true, // Inject all files that are generated by webpack, e.g. bundle.js
template: 'src/index.html',
}),
new CircularDependencyPlugin({
exclude: /a\.js|node_modules/, // exclude node_modules
failOnError: false, // show a warning when there is a circular dependency
exclude: /node_modules/,
include: /src/,
failOnError: false,
allowAsyncCycles: false,
cwd: process.cwd()
}),
],
devtool: 'cheap-module-source-map',
......
// Important modules this config uses
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WebpackPwaManifest = require('webpack-pwa-manifest');
// const OfflinePlugin = require('offline-plugin');
const { HashedModuleIdsPlugin } = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
module.exports = require('./webpack.base.babel')({
mode: 'production',
......@@ -17,10 +13,10 @@ module.exports = require('./webpack.base.babel')({
],
// Utilize long-term caching by adding content hashes (not compilation hashes) to compiled assets
output: {
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].chunk.js',
},
// output: {
// filename: '[name].[chunkhash].js',
// chunkFilename: '[name].[chunkhash].chunk.js',
// },
optimization: {
minimize: true,
......@@ -44,15 +40,17 @@ module.exports = require('./webpack.base.babel')({
}),
],
nodeEnv: 'production',
namedModules: true,
usedExports: true,
sideEffects: true,
concatenateModules: true,
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: 10,
minSize: 0,
cacheGroups: {
vendor: {
vendor: {
chunks: 'all',
minSize: 0,
maxInitialRequests: 35,
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(
......@@ -61,53 +59,25 @@ module.exports = require('./webpack.base.babel')({
return `npm.${packageName.replace('@', '')}`;
},
},
bizComponent: {
chunks: 'all',
minSize: 0,
maxInitialRequests: 10,
test: /[\\/]src[\\/]components[\\/]/,
name: 'biz-component',
},
react: {
chunks: 'all',
minSize: 0,
maxInitialRequests: 10,
test: /[\\/]node_modules[\\/]react-dom[\\/]/,
name: 'react-dom',
}
},
},
},
plugins: [
// Minify and optimize the index.html
new HtmlWebpackPlugin({
template: 'src/index.html',
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
inject: true,
}),
// Put it in the end to capture all the HtmlWebpackPlugin's
// // assets manipulations and do leak its manipulations to HtmlWebpackPlugin
// new OfflinePlugin({
// relativePaths: false,
// publicPath: '/',
// appShell: '/',
//
// // No need to cache .htaccess. See http://mxs.is/googmp,
// // this is applied before any match in `caches` section
// excludes: ['.htaccess'],
//
// caches: {
// main: [':rest:'],
//
// // All chunks marked as `additional`, loaded after main section
// // and do not prevent SW to install. Change to `optional` if
// // do not want them to be preloaded at all (cached only when first loaded)
// additional: ['*.chunk.js'],
// },
//
// // Removes warning for about `additional` section usage
// safeToUseOptionalCaches: true,
// }),
new CompressionPlugin({
algorithm: 'gzip',
test: /\.js$|\.css$|\.html$/,
......@@ -115,39 +85,11 @@ module.exports = require('./webpack.base.babel')({
minRatio: 0.8,
}),
new WebpackPwaManifest({
name: '熊猫智慧城市监控管理解决方案',
short_name: '熊猫智慧城市监控管理解决方案',
description: '熊猫智慧城市监控管理解决方案',
background_color: '#fafafa',
theme_color: '#b1624d',
inject: true,
ios: true,
icons: [
{
src: path.resolve('src/images/icon-512x512.png'),
sizes: [72, 96, 128, 144, 192, 384, 512],
},
{
src: path.resolve('src/images/icon-512x512.png'),
sizes: [120, 152, 167, 180],
ios: true,
},
],
}),
new HashedModuleIdsPlugin({
hashFunction: 'sha256',
hashDigest: 'hex',
hashDigestLength: 20,
}),
// new WebpackManifestPlugin({
// publicPath: '/civbase/',
// map: (file) => {
// file.name = file.name.replace(/(\.[a-f0-9]{32})(\..*)$/, '$2');
// return file;
// }
// })
],
performance: {
......
// @ts-ignore
//import { Request, Response } from 'express';
module.exports = {
'GET /api/currentUser': (req, res) => {
res
.status(200)
.send({
name: '韩磊',
avatar: '',
userid: 'de98FdAe-1fcA-985e-7EDe-A79E8FFA854E',
email: 'a.lrl@mffnge.ph',
signature: '般立层子米基断北得行办的七住。',
title: '做众亲子所化下基计称数照。',
group: '服务技术部',
tags: [
{ key: 1, label: 'IT 互联网' },
{ key: 2, label: '海纳百川' },
{ key: 3, label: '川妹子' },
{ key: 4, label: '海纳百川' },
{ key: 5, label: '算法工程师' },
{ key: 6, label: '很有想法的' },
{ key: 7, label: 'IT 互联网' },
{ key: 8, label: '专注设计' },
],
notifyCount: 93,
unreadCount: 70,
country: '韩国',
access: '众因变无律周体严器外在不根。',
geographic: {
province: { label: '新疆维吾尔自治区', key: 9 },
city: { label: '珠海市', key: 10 },
},
address: '河南省 南阳市 桐柏县',
phone: '11283974361',
});
},
'GET /api/notices': (req, res) => {
res
.status(200)
.send({
data: [
{
id: '26fd5659-6818-c9Ee-CdCF-Bc69FBf157F5',
extra: 'FreB',
key: 12,
read: true,
avatar: 'https://avatars1.githubusercontent.com/u/8186664?s=40&v=4',
title: '万究改非走命造之可从参打最。',
status: 'default',
datetime: '1980-10-19',
description: '有青设加包阶手别无往向导年关参才管复。',
type: 'notification',
},
{
id: '8b52fe55-2887-AC2B-Db2B-1fD3Ea9beeE2',
extra: '9uQO$Jh',
key: 13,
read: false,
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '往条再习价机指北很些参转派。',
status: 'error',
datetime: '1988-12-24',
description: '很格连然实验九一眼到号适。',
type: 'notification',
},
{
id: 'Ff1312b7-34bd-d9FC-FC2a-a34D6eCEEbD2',
extra: '(Oe6',
key: 14,
read: false,
avatar:
'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
title: '广级般千此这于节相制认要特革。',
status: 'processing',
datetime: '1975-10-13',
description: '亲适地新水那图广候今属活法低正求。',
type: 'notification',
},
{
id: 'B353AcAB-d9FE-DCa5-309E-AfF43bC2DD92',
extra: 'Z@Z^ij',
key: 15,
read: false,
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
title: '家不发经得器形如布力到议调采引。',
status: 'processing',
datetime: '1996-11-23',
description: '后何完十称利任里石须连因思。',
type: 'notification',
},
{
id: '4fe4A8b3-B6E5-dC3d-3864-f4da4fcF1d3f',
extra: 'b7OW',
key: 16,
read: false,
avatar:
'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
title: '观现太照号真安第活增日离准说写为这。',
status: 'processing',
datetime: '1975-04-07',
description: '厂克装省期那两八在别真通新府。',
type: 'notification',
},
{
id: '4Eefc7d3-eec7-eEC6-fDf5-EF9AF8C158B7',
extra: 't5%p',
key: 17,
read: true,
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '图面济习果然选打儿往并进美。',
status: 'default',
datetime: '1981-07-21',
description: '之记议按气不人劳清且院日。',
type: 'notification',
},
{
id: 'e368F8dc-B236-04Ab-cB05-B1D6A541Da2C',
extra: 'GuGb5',
key: 18,
read: true,
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
title: '海准到团权题时住称即按常火制。',
status: 'error',
datetime: '2014-09-18',
description: '入者属时思因至小文保美管好已电音可上。',
type: 'notification',
},
{
id: 'bD4EfbDc-5337-eec7-DaDB-FedABF06F884',
extra: '^#(b',
key: 19,
read: false,
avatar: '',
title: '次话织才决色素马型规毛员准越住林。',
status: 'warning',
datetime: '1998-09-05',
description: '化属新道商步响酸非历至该风四维属需。',
type: 'notification',
},
{
id: 'ab69bfDD-f535-ADbb-Cf3d-E5CA7DbEF2ad',
extra: '(DAIG',
key: 20,
read: true,
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
title: '流较术合联风样少节打体中门八。',
status: 'default',
datetime: '1996-01-03',
description: '改原非还着取步效只华农名社。',
type: 'notification',
},
{
id: '418C7EeA-fDbC-843d-F76D-2BC23A9e8eF2',
extra: 'suvQ$O',
key: 21,
read: false,
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
title: '为公受条总此类影所提无受万南非事具。',
status: 'default',
datetime: '1975-12-08',
description: '间特快装铁我品给求六片由青信区。',
type: 'notification',
},
{
id: 'ac9F7ae7-F3d2-bC14-cC5D-a38Fca151Eac',
extra: 'HIX9@)',
key: 22,
read: true,
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
title: '展生起而两边断指内布数点铁压具。',
status: 'processing',
datetime: '2004-11-21',
description: '观织回走此性写任主在设新力小这想。',
type: 'notification',
},
{
id: 'c41f9c0A-cBDc-F07F-B85D-5DC3d0574d77',
extra: 'Bwlc!Bq',
key: 23,
read: true,
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
title: '或内局段花革器规关价快和口音安京。',
status: 'default',
datetime: '1994-08-07',
description: '有增史子太采只月则全革百习风此强。',
type: 'notification',
},
],
total: 63,
success: false,
});
},
};
// @ts-ignore
//import { Request, Response } from 'express';
module.exports = {};
// @ts-ignore
//import { Request, Response } from 'express';
module.exports = {
'POST /api/login/captcha': (req, res) => {
res.status(200).send({ code: 62, status: 'error' });
},
'POST /api/login/outLogin': (req, res) => {
res.status(200).send({});
},
'POST /api/login/account': (req, res) => {
res.status(200).send({ status: 'default', type: 11, currentAuthority: 'user' });
},
};
module.exports = {
'GET /api/notices': {
id: '000000002',
avatar:
'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
title: '曲丽丽 评论了你',
description: '描述信息描述信息描述信息',
datetime: '2017-08-07',
type: 'message',
clickClose: true,
},
};
// @ts-ignore
//import { Request, Response } from 'express';
module.exports = {};
// @ts-ignore
//import { Request, Response } from 'express';
module.exports = {
'GET /api/rule': (req, res) => {
res
.status(200)
.send({
data: [
{
key: 77,
disabled: true,
href: 'https://umijs.org/',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
name: '杜明',
owner: 'Johnson',
desc: '展金习设许此备还育住第即但没新何进。',
callNo: 75,
status: 69,
updatedAt: 'z*GGqY',
createdAt: 'OgCEx15',
progress: 81,
},
{
key: 72,
disabled: true,
href: 'https://ant.design',
avatar: 'https://avatars0.githubusercontent.com/u/507615?s=40&v=4',
name: '龙伟',
owner: 'Moore',
desc: '近区置世意史风品容等量引律养级马理。',
callNo: 72,
status: 63,
updatedAt: 'o%NS',
createdAt: 'HJo',
progress: 89,
},
{
key: 98,
disabled: true,
href: 'https://procomponents.ant.design/',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
name: '韩军',
owner: 'Hall',
desc: '二应据称感号单常强持社少便快极西流能。',
callNo: 82,
status: 71,
updatedAt: '2jgCyz',
createdAt: '&d$kEH',
progress: 70,
},
{
key: 94,
disabled: false,
href: 'https://preview.pro.ant.design/dashboard/analysis',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
name: '刘平',
owner: 'Lopez',
desc: '大管别消证物拉主今解过格科家角。',
callNo: 71,
status: 97,
updatedAt: 'u5Y',
createdAt: '4xJ5O',
progress: 78,
},
{
key: 74,
disabled: true,
href: 'https://ant.design',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg',
name: '苏娟',
owner: 'Miller',
desc: '需八相严平写今的快验二历林。',
callNo: 76,
status: 89,
updatedAt: 'Roob',
createdAt: 'hikM9o',
progress: 92,
},
{
key: 92,
disabled: false,
href: 'https://preview.pro.ant.design/dashboard/analysis',
avatar: 'https://avatars0.githubusercontent.com/u/507615?s=40&v=4',
name: '赖霞',
owner: 'Taylor',
desc: '采众用我类拉标技政般酸往得。',
callNo: 79,
status: 78,
updatedAt: 'Af9Y%',
createdAt: 'n*M4H',
progress: 66,
},
{
key: 99,
disabled: false,
href: '',
avatar:
'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
name: '何杰',
owner: 'Young',
desc: '段除然到社包示上来化文将机思。',
callNo: 67,
status: 99,
updatedAt: 'v!T9b',
createdAt: '3NS@',
progress: 69,
},
{
key: 88,
disabled: false,
href: 'https://procomponents.ant.design/',
avatar: 'https://avatars0.githubusercontent.com/u/507615?s=40&v=4',
name: '冯娟',
owner: 'Johnson',
desc: '公与起拉记龙应二家种定科。',
callNo: 68,
status: 96,
updatedAt: 'hV6*R6',
createdAt: 'FrTdqU',
progress: 71,
},
{
key: 66,
disabled: false,
href: 'https://github.com/umijs/dumi',
avatar: 'https://avatars1.githubusercontent.com/u/8186664?s=40&v=4',
name: '杜刚',
owner: 'Lewis',
desc: '收花领养克听关消克般时电自必需论。',
callNo: 72,
status: 98,
updatedAt: 's*t',
createdAt: 'uby3w',
progress: 68,
},
{
key: 71,
disabled: true,
href: 'https://procomponents.ant.design/',
avatar: 'https://avatars0.githubusercontent.com/u/507615?s=40&v=4',
name: '戴芳',
owner: 'Jackson',
desc: '也天下京完指际保手上劳响什部多。',
callNo: 85,
status: 64,
updatedAt: 'YIzwv',
createdAt: 'x[Z',
progress: 86,
},
{
key: 63,
disabled: true,
href: 'https://procomponents.ant.design/',
avatar: 'https://avatars1.githubusercontent.com/u/8186664?s=40&v=4',
name: '赖艳',
owner: 'Brown',
desc: '之示气上你力表清力队气消全划山路。',
callNo: 72,
status: 66,
updatedAt: '(6U0',
createdAt: 'WVSoNJ',
progress: 84,
},
],
total: 99,
success: true,
});
},
'POST /api/rule': (req, res) => {
res
.status(200)
.send({
key: 71,
disabled: true,
href: 'https://ant.design',
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
name: '段勇',
owner: 'Thomas',
desc: '院题质数下布进或会府速体快型前快。',
callNo: 91,
status: 88,
updatedAt: 'T$frcd',
createdAt: '#]MhT%',
progress: 79,
});
},
'PUT /api/rule': (req, res) => {
res
.status(200)
.send({
key: 94,
disabled: true,
href: 'https://umijs.org/',
avatar: 'https://avatars0.githubusercontent.com/u/507615?s=40&v=4',
name: '常桂英',
owner: 'Perez',
desc: '布华意王去消候研格作指称。',
callNo: 61,
status: 97,
updatedAt: 'ZX0wE7',
createdAt: 'mg%',
progress: 93,
});
},
'DELETE /api/rule': (req, res) => {
res.status(200).send({});
},
};
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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