Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivWeb
Commits
d84a7adb
Commit
d84a7adb
authored
Apr 15, 2022
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 代理添加热更新
parent
c8acba2c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
index.js
server/index.js
+5
-5
server.js
server/server.js
+1
-1
cleanRequireCache.js
server/utils/cleanRequireCache.js
+2
-0
No files found.
server/index.js
View file @
d84a7adb
...
...
@@ -12,7 +12,7 @@ const mockMiddewares = require('./mock');
const
emitter
=
require
(
'./event'
);
const
Server
=
require
(
'./server'
);
const
debug
=
createDebug
(
'preset-build-in:proxy:createMiddleware'
);
const
proxyConfig
=
require
(
'../config/proxy'
);
//
const proxyConfig = require('../config/proxy');
const
loadDotEnv
=
require
(
'./utils/loadDotEnv'
);
const
{
getSchema
}
=
require
(
'./openapi'
);
const
cleanRequireCache
=
require
(
'./utils/cleanRequireCache'
);
...
...
@@ -113,12 +113,12 @@ const cleanRequireCache = require('./utils/cleanRequireCache');
const
errors
=
[];
watcher
.
on
(
'ready'
,
()
=>
debug
(
'Initial scan complete. Ready for changes'
)).
on
(
'all'
,
async
(
event
,
file
)
=>
{
debug
(
`[
${
event
}
]
${
file
}
, reload proxy config`
);
debug
(
`[
${
event
}
]
${
file
}
, reload proxy config`
);
``
errors
.
splice
(
0
,
errors
.
length
);
cleanRequireCache
(
proxyWatcherPaths
);
// eslint-disable-next-line no-const-assign
cleanRequireCache
(
Array
.
from
(
new
Set
(
proxyWatcherPaths
)));
if
(
!
errors
.
length
)
{
server
.
setupProxy
&&
server
.
setupProxy
(
proxyConfig
[
process
.
env
.
NODE_ENV
],
true
);
const
hotProxy
=
require
(
'../config/proxy'
);
server
.
setupProxy
&&
server
.
setupProxy
(
hotProxy
[
process
.
env
.
NODE_ENV
],
true
);
signale
.
success
(
`Proxy config parse success`
);
}
});
...
...
server/server.js
View file @
d84a7adb
...
...
@@ -134,7 +134,7 @@ class Server {
);
}
setupProxy
(
proxyOpts
,
isWatch
=
tru
e
)
{
setupProxy
(
proxyOpts
,
isWatch
=
fals
e
)
{
let
proxy
=
proxyOpts
||
this
.
opts
.
proxy
;
if
(
!
Array
.
isArray
(
proxy
))
{
if
(
proxy
&&
'target'
in
proxy
)
{
...
...
server/utils/cleanRequireCache.js
View file @
d84a7adb
const
{
winPath
}
=
require
(
'@umijs/utils'
)
function
cleanRequireCache
(
paths
)
{
Object
.
keys
(
require
.
cache
).
forEach
(
file
=>
{
if
(
paths
.
some
(
p
=>
winPath
(
file
).
indexOf
(
p
)
>
-
1
))
{
console
.
log
(
file
);
delete
require
.
cache
[
file
];
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment