mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-08-10 13:19:59 +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",
|
"style-loader": "^2.0.0",
|
||||||
"url-loader": "^4.1.1",
|
"url-loader": "^4.1.1",
|
||||||
"vue-loader": "^16.1.2",
|
"vue-loader": "^16.1.2",
|
||||||
|
"connect-history-api-fallback": "^1.6.0",
|
||||||
"webpack": "^5.24.2",
|
"webpack": "^5.24.2",
|
||||||
"webpack-bundle-analyzer": "^4.4.0",
|
"webpack-bundle-analyzer": "^4.4.0",
|
||||||
"webpack-chain": "^6.5.1",
|
"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
|
getBundleAndConfigs
|
||||||
} = require('../buildDevUtils');
|
} = require('../buildDevUtils');
|
||||||
const { delay } = require('@umijs/utils');
|
const { delay } = require('@umijs/utils');
|
||||||
|
const createRouteMiddleware = require('./createRouteMiddleware').default;
|
||||||
const generateFiles = require('../../../utils/generateFiles').default;
|
const generateFiles = require('../../../utils/generateFiles').default;
|
||||||
const { watchPkg } = require('./watchPkg');
|
const { watchPkg } = require('./watchPkg');
|
||||||
|
|
||||||
@ -175,7 +176,7 @@ export default (api) => {
|
|||||||
port,
|
port,
|
||||||
proxy: api.config.proxy,
|
proxy: api.config.proxy,
|
||||||
https: isHTTPS,
|
https: isHTTPS,
|
||||||
beforeMiddlewares,
|
beforeMiddlewares: [...beforeMiddlewares, createRouteMiddleware()],
|
||||||
afterMiddlewares: [...middlewares],
|
afterMiddlewares: [...middlewares],
|
||||||
customerDevServerConfig: api.config.devServer
|
customerDevServerConfig: api.config.devServer
|
||||||
});
|
});
|
||||||
|
@ -2,17 +2,16 @@
|
|||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// base: '',
|
base: '/base/',
|
||||||
qiankun: {
|
|
||||||
micro: {}
|
|
||||||
},
|
|
||||||
define: {
|
define: {
|
||||||
__DEV__: false
|
__DEV__: false
|
||||||
},
|
},
|
||||||
html: {
|
html: {
|
||||||
title: '海贼王'
|
title: '海贼王'
|
||||||
},
|
},
|
||||||
publicPath: '/',
|
router: {
|
||||||
|
mode: 'history'
|
||||||
|
},
|
||||||
access: {
|
access: {
|
||||||
roles: {
|
roles: {
|
||||||
admin: ["/", "/store", "https://www.baidu.com"]
|
admin: ["/", "/store", "https://www.baidu.com"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user