mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-08-07 18:39:45 +08:00
feat: 支持history模式下请求html文件404时fallback到/index.html
This commit is contained in:
parent
a9a615a09b
commit
19108db7ce
@ -65,6 +65,7 @@
|
||||
"style-loader": "^2.0.0",
|
||||
"url-loader": "^4.1.1",
|
||||
"vue-loader": "^16.1.2",
|
||||
"connect-history-api-fallback": "^1.6.0",
|
||||
"webpack": "^5.24.2",
|
||||
"webpack-bundle-analyzer": "^4.4.0",
|
||||
"webpack-chain": "^6.5.1",
|
||||
|
@ -0,0 +1,16 @@
|
||||
|
||||
import { extname, join } from 'path';
|
||||
import historyFallback from 'connect-history-api-fallback';
|
||||
|
||||
const ASSET_EXTNAMES = ['.ico', '.png', '.jpg', '.jpeg', '.gif', '.svg'];
|
||||
|
||||
export default () => (req, res, next) => {
|
||||
if (req.path === '/favicon.ico') {
|
||||
res.sendFile(join(__dirname, 'fes.png'));
|
||||
} else if (ASSET_EXTNAMES.includes(extname(req.path))) {
|
||||
next();
|
||||
} else {
|
||||
const history = historyFallback();
|
||||
history(req, res, next);
|
||||
}
|
||||
};
|
BIN
packages/fes-preset-built-in/src/plugins/commands/dev/fes.png
Normal file
BIN
packages/fes-preset-built-in/src/plugins/commands/dev/fes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
@ -40,6 +40,7 @@ export default (api) => {
|
||||
getBundleAndConfigs
|
||||
} = require('../buildDevUtils');
|
||||
const { delay } = require('@umijs/utils');
|
||||
const createRouteMiddleware = require('./createRouteMiddleware').default;
|
||||
const generateFiles = require('../../../utils/generateFiles').default;
|
||||
const { watchPkg } = require('./watchPkg');
|
||||
|
||||
@ -175,7 +176,7 @@ export default (api) => {
|
||||
port,
|
||||
proxy: api.config.proxy,
|
||||
https: isHTTPS,
|
||||
beforeMiddlewares,
|
||||
beforeMiddlewares: [...beforeMiddlewares, createRouteMiddleware()],
|
||||
afterMiddlewares: [...middlewares],
|
||||
customerDevServerConfig: api.config.devServer
|
||||
});
|
||||
|
@ -2,17 +2,16 @@
|
||||
|
||||
|
||||
export default {
|
||||
// base: '',
|
||||
qiankun: {
|
||||
micro: {}
|
||||
},
|
||||
base: '/base/',
|
||||
define: {
|
||||
__DEV__: false
|
||||
},
|
||||
html: {
|
||||
title: '海贼王'
|
||||
},
|
||||
publicPath: '/',
|
||||
router: {
|
||||
mode: 'history'
|
||||
},
|
||||
access: {
|
||||
roles: {
|
||||
admin: ["/", "/store", "https://www.baidu.com"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user