Skip to content
This repository has been archived by the owner on May 8, 2022. It is now read-only.

fix 基于umi v3 升级 #37

Merged
merged 1 commit into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .editorconfig
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "eslint-config-umi"
}
12 changes: 0 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Created by .ignore support plugin (hsz.mobi)
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

#idea
.idea
.idea/**.*

# dependencies
/node_modules
/npm-debug.log*
Expand All @@ -21,10 +16,3 @@
# umi
.umi
.umi-production


# 部署目录
/dist

# 测试覆盖率统计
/coverage
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"singleQuote": true,
"trailingComma": "es5",
"trailingComma": "all",
"printWidth": 100,
"overrides": [
{
Expand Down
16 changes: 0 additions & 16 deletions .stylelintrc.json

This file was deleted.

143 changes: 31 additions & 112 deletions config/config.ts
Original file line number Diff line number Diff line change
@@ -1,136 +1,55 @@
// https://umijs.org/config/
import os from 'os';
import path from 'path';
import { IPlugin, IConfig } from 'umi-types';
import pxToViewPort from 'postcss-px-to-viewport';
import defaultSettings from './defaultSettings';
import { IConfig } from 'umi-types';
import pageRoutes from './router.config';
const { pwa, primaryColor } = defaultSettings;

const { TEST, NODE_ENV } = process.env;
const plugins: IPlugin[] = [
[
'umi-plugin-react',
{
// ref: https://umijs.org/config/
const config: IConfig = {
treeShaking: true,
routes: pageRoutes,
plugins: [
// ref: https://umijs.org/plugin/umi-plugin-react.html
['umi-plugin-react', {
antd: true,
dva: true,
fastClick: true,
autoprefixer:'',
// hd: true,
dll: true,
hardSource: false,
locale: {
// default false
enable: true,
// default zh-CN
default: 'zh-CN',
// default true, when it is true, will use `navigator.language` overwrite default
baseNavigator: true,
},
dynamicImport: {
loadingComponent: './components/PageLoading/index',
webpackChunkName: true,
level: 3,
},
library: 'react',
metas: [{ charset: 'utf-8' }],
pwa: pwa
? {
workboxPluginMode: 'InjectManifest',
workboxOptions: {
importWorkboxFrom: 'local',
},
}
: false,
...(!TEST && os.platform() === 'darwin'
? {
dll: {
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
exclude: ['@babel/runtime'],
},
hardSource: false,
}
: {}),
},
title: 'umi-dva-antd-mobile',
dll: true,
hd: true,
locale: {
enable: true,
default: 'en-US',
},
routes: {
exclude: [
/models\//,
/services\//,
/model\.(t|j)sx?$/,
/service\.(t|j)sx?$/,
/components\//,
],
},
}],
],
];

const uglifyJSOptions =
NODE_ENV === 'production'
? {
uglifyOptions: {
// remove console.* except console.error
compress: {
drop_console: true,
pure_funcs: ['console.error'],
},
},
}
: {};
export default {
// add for transfer to umi
base: '',
publicPath: '',
history: 'hash', // 默认是 browser
plugins,
define: {
APP_TYPE: process.env.APP_TYPE || '',
},
treeShaking: true,
targets: {
ie: 11,
android: 5,
ios: 7,
chrome: 58,
},
devtool: false,
// 路由配置
routes: pageRoutes,
// Theme for antd
// https://ant.design/docs/react/customize-theme-cn
theme: {
'primary-color': primaryColor,
},
proxy: {
'/server/api/': {
changeOrigin: true,
pathRewrite: { '^/server': '' },
target: 'https://preview.pro.ant.design/',
},
'/wx/api/': {
changeOrigin: true,
pathRewrite: { '^/wx/api': '' },
target: 'https://games.parsec.com.cn/',
},
},
history: 'hash', // 默认是 browser
ignoreMomentLocale: true,
lessLoaderOptions: {
javascriptEnabled: true,
},
disableRedirectHoist: true,
cssLoaderOptions: {
modules: true,
},
outputPath: './dist',
hash: true,
manifest: {
basePath: '/',
},
uglifyJSOptions,
alias: {
'@': path.resolve(__dirname, 'src'),
},
chainWebpack: config => {},
extraBabelPlugins:[
['import', { libraryName: 'antd-mobile', style: true }] //按需加载antd-mobile样式文件
],
extraPostCSSPlugins: [
pxToViewPort({
viewportWidth: 375,
viewportHeight: 667,
unitPrecision: 5,
viewportUnit: 'vw',
selectorBlackList: [],
minPixelValue: 1,
mediaQuery: false,
}),
],
} as IConfig;
};

export default config;
76 changes: 5 additions & 71 deletions config/router.config.ts
Original file line number Diff line number Diff line change
@@ -1,78 +1,12 @@
export default [
// user
{
path: '/user',
component: '../layouts/UserLayout',
routes: [
{ path: '/user', redirect: '/user/login' },
{ path: '/user/login', component: './User/Login' },
],
},
// TabBar
{
path: '/tabbar',
component: '../layouts/TabBarLayout',
routes: [
{ path: '/tabbar', redirect: '/tabbar/index' },
{
path: '/tabbar/index',
title: 'index',
component: './tabbar/index',
iconName: 'alipay',
},
{
path: '/tabbar/koubei',
title: 'Koubei',
component: './tabbar/Koubei',
iconName: 'koubei',
},
{
path: '/tabbar/friend',
title: 'Friend',
component: './tabbar/Friend',
iconName: 'friend',
},
{
path: '/tabbar/my',
title: 'My',
component: './tabbar/Koubei',
iconName: 'my',
},
],
},
// H5
{
path: '/',
component: '../layouts/BasicLayout',
Routes: ['src/pages/Authorized'],
authority: ['user', 'admin'],
component: '../layouts/index',
// Routes: ['src/pages/Authorized'],
// authority: ['user', 'admin'],
routes: [
{ path: '/', component: './home/index', title: '首页' },
{ path: '/entrance', component: './entrance/index', title: '主入口' },
{ path: '/paper/:type', component: './paper/index', title: '试题页面' },
{ path: '/result', component: './result/index', title: '结果页' },
{
title: 'exception',
path: '/exception',
routes: [
// Exception
{
path: '/exception/403',
title: 'not-permission',
component: './exception/403',
},
{
path: '/exception/404',
title: 'not-find',
component: './exception/404',
},
{
path: '/exception/500',
title: 'server-error',
component: './exception/500',
},
],
},
{ path: '/', component: './index', title: '首页' },
{ path: '/me', component: './me', title: '个人中心' },
{ path: '/404', component: '404' },
],
},
Expand Down
4 changes: 0 additions & 4 deletions jest.config.js

This file was deleted.

Empty file added mock/.gitkeep
Empty file.
Loading