From 627094232413f190f039f137aff552dfb3335b45 Mon Sep 17 00:00:00 2001 From: popomore Date: Fri, 24 Jun 2022 13:34:55 +0800 Subject: [PATCH] feat: refactor umi --- app/view/.umirc.js | 30 --------------------- app/view/.umirc.ts | 3 --- app/view/index.html | 33 ++++++++++++++++------- app/view/package.json | 17 ------------ app/{view => web}/.editorconfig | 0 app/{view => web}/.env | 0 app/{view => web}/.eslintrc | 0 app/{view => web}/.gitignore | 0 app/{view => web}/.npmrc | 0 app/{view => web}/.prettierignore | 0 app/{view => web}/.prettierrc | 0 app/web/.umirc.ts | 14 ++++++++++ app/{view => web}/src/assets/yay.jpg | Bin app/{view => web}/src/layouts/index.less | 0 app/{view => web}/src/layouts/index.tsx | 0 app/{view => web}/src/pages/docs.tsx | 0 app/{view => web}/src/pages/index.tsx | 0 app/{view => web}/tsconfig.json | 0 app/{view => web}/typings.d.ts | 0 config/config.default.js | 15 +++++------ 20 files changed, 45 insertions(+), 67 deletions(-) delete mode 100644 app/view/.umirc.js delete mode 100644 app/view/.umirc.ts delete mode 100644 app/view/package.json rename app/{view => web}/.editorconfig (100%) rename app/{view => web}/.env (100%) rename app/{view => web}/.eslintrc (100%) rename app/{view => web}/.gitignore (100%) rename app/{view => web}/.npmrc (100%) rename app/{view => web}/.prettierignore (100%) rename app/{view => web}/.prettierrc (100%) create mode 100644 app/web/.umirc.ts rename app/{view => web}/src/assets/yay.jpg (100%) rename app/{view => web}/src/layouts/index.less (100%) rename app/{view => web}/src/layouts/index.tsx (100%) rename app/{view => web}/src/pages/docs.tsx (100%) rename app/{view => web}/src/pages/index.tsx (100%) rename app/{view => web}/tsconfig.json (100%) rename app/{view => web}/typings.d.ts (100%) diff --git a/app/view/.umirc.js b/app/view/.umirc.js deleted file mode 100644 index cad269a..0000000 --- a/app/view/.umirc.js +++ /dev/null @@ -1,30 +0,0 @@ - -// ref: https://umijs.org/config/ -export default { - treeShaking: true, - routes: [ - { - path: '/', - component: '../layouts/index', - routes: [ - { path: '/', component: '../pages/index' } - ] - } - ], - plugins: [ - // ref: https://umijs.org/plugin/umi-plugin-react.html - ['umi-plugin-react', { - antd: false, - dva: false, - dynamicImport: false, - title: 'view', - dll: false, - - routes: { - exclude: [ - /components\//, - ], - }, - }], - ], -} diff --git a/app/view/.umirc.ts b/app/view/.umirc.ts deleted file mode 100644 index 9ff3b7e..0000000 --- a/app/view/.umirc.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default { - npmClient: 'npm' -}; diff --git a/app/view/index.html b/app/view/index.html index 96845ce..2c0780c 100644 --- a/app/view/index.html +++ b/app/view/index.html @@ -1,10 +1,25 @@ - + - - - - -
- - - \ No newline at end of file + + + + + + + + +{{ helper.assets.getStyle('umi.css') | safe }} + + + +
+ + + +{{ helper.assets.getScript('umi.js') | safe }} + + diff --git a/app/view/package.json b/app/view/package.json deleted file mode 100644 index e97d54b..0000000 --- a/app/view/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "private": true, - "scripts": { - "dev": "umi dev", - "build": "umi build", - "postinstall": "umi setup", - "start": "npm run dev" - }, - "dependencies": { - "umi": "^4.0.1" - }, - "devDependencies": { - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", - "typescript": "^4.1.2" - } -} diff --git a/app/view/.editorconfig b/app/web/.editorconfig similarity index 100% rename from app/view/.editorconfig rename to app/web/.editorconfig diff --git a/app/view/.env b/app/web/.env similarity index 100% rename from app/view/.env rename to app/web/.env diff --git a/app/view/.eslintrc b/app/web/.eslintrc similarity index 100% rename from app/view/.eslintrc rename to app/web/.eslintrc diff --git a/app/view/.gitignore b/app/web/.gitignore similarity index 100% rename from app/view/.gitignore rename to app/web/.gitignore diff --git a/app/view/.npmrc b/app/web/.npmrc similarity index 100% rename from app/view/.npmrc rename to app/web/.npmrc diff --git a/app/view/.prettierignore b/app/web/.prettierignore similarity index 100% rename from app/view/.prettierignore rename to app/web/.prettierignore diff --git a/app/view/.prettierrc b/app/web/.prettierrc similarity index 100% rename from app/view/.prettierrc rename to app/web/.prettierrc diff --git a/app/web/.umirc.ts b/app/web/.umirc.ts new file mode 100644 index 0000000..d2ce8bc --- /dev/null +++ b/app/web/.umirc.ts @@ -0,0 +1,14 @@ +// ref: https://umijs.org/config/ +export default { + npmClient: 'npm', + routes: [ + { + path: '/', + component: '../layouts/index', + routes: [ + { path: '/', component: '../pages/index' } + ] + } + ], + runtimePublicPath: {}, +} diff --git a/app/view/src/assets/yay.jpg b/app/web/src/assets/yay.jpg similarity index 100% rename from app/view/src/assets/yay.jpg rename to app/web/src/assets/yay.jpg diff --git a/app/view/src/layouts/index.less b/app/web/src/layouts/index.less similarity index 100% rename from app/view/src/layouts/index.less rename to app/web/src/layouts/index.less diff --git a/app/view/src/layouts/index.tsx b/app/web/src/layouts/index.tsx similarity index 100% rename from app/view/src/layouts/index.tsx rename to app/web/src/layouts/index.tsx diff --git a/app/view/src/pages/docs.tsx b/app/web/src/pages/docs.tsx similarity index 100% rename from app/view/src/pages/docs.tsx rename to app/web/src/pages/docs.tsx diff --git a/app/view/src/pages/index.tsx b/app/web/src/pages/index.tsx similarity index 100% rename from app/view/src/pages/index.tsx rename to app/web/src/pages/index.tsx diff --git a/app/view/tsconfig.json b/app/web/tsconfig.json similarity index 100% rename from app/view/tsconfig.json rename to app/web/tsconfig.json diff --git a/app/view/typings.d.ts b/app/web/typings.d.ts similarity index 100% rename from app/view/typings.d.ts rename to app/web/typings.d.ts diff --git a/config/config.default.js b/config/config.default.js index 737e8a4..cbe8aa8 100644 --- a/config/config.default.js +++ b/config/config.default.js @@ -27,23 +27,22 @@ module.exports = appInfo => { dir: path.join(appInfo.baseDir, 'app/public'), }, view: { - root: [ - path.join(appInfo.baseDir, 'app/view'), - ].join(','), + root: path.join(appInfo.baseDir, 'app/view'), mapping: { - '.nj': 'nunjucks', - '.js': 'assets', + '.html': 'nunjucks', }, - defaultViewEngine: 'nunjucks', }, assets: { publicPath: '/public/', devServer: { debug: true, - command: 'cross-env REACT_APP_ENV=dev MOCK=none APP_ROOT=$PWD/app/view USE_WEBPACK_5=1 UMI_ENV=dev umi dev', + command: 'umi dev', port: 8000, env: { - APP_ROOT: path.join(__dirname, 'app/view'), + USE_WEBPACK_5: 1, + UMI_ENV: 'dev', + REACT_APP_ENV: 'devumi', + APP_ROOT: path.join(__dirname, '../app/web'), BROWSER: 'none', ESLINT: 'none', SOCKET_SERVER: 'http://127.0.0.1:8000',