-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: webpack-dev 升级到5.x,提升 dev 性能,优化日志输出 (#259)
- Loading branch information
Showing
7 changed files
with
1,863 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 14 additions & 12 deletions
26
packages/fes-builder-webpack/src/plugins/commands/dev/connectHistoryMiddleware.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import { extname } from 'path'; | ||
import { extname } from 'node:path'; | ||
import historyFallback from 'connect-history-api-fallback'; | ||
|
||
const ASSET_EXT_NAMES = ['.ico', '.png', '.jpg', '.jpeg', '.gif', '.svg']; | ||
|
||
const proxyMiddleware = (api) => (req, res, next) => { | ||
const proxyConfig = api.config.proxy; | ||
if (proxyConfig && Object.keys(proxyConfig).some((path) => req.url.startsWith(path))) { | ||
return next(); | ||
} | ||
if (ASSET_EXT_NAMES.includes(extname(req.url))) { | ||
return next(); | ||
} | ||
function proxyMiddleware(api) { | ||
return (req, res, next) => { | ||
const proxyConfig = api.config.proxy; | ||
if (proxyConfig && Object.keys(proxyConfig).some(path => req.url.startsWith(path))) { | ||
return next(); | ||
} | ||
if (ASSET_EXT_NAMES.includes(extname(req.url))) { | ||
return next(); | ||
} | ||
|
||
const history = historyFallback(); | ||
history(req, res, next); | ||
}; | ||
const history = historyFallback(); | ||
history(req, res, next); | ||
}; | ||
} | ||
|
||
export default proxyMiddleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
packages/fes-builder-webpack/src/plugins/commands/dev/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.