FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
webpack/lib/NormalModuleReplacementPlugin.js at master · codeinvain/webpack · GitHub
codeinvain
webpack
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
webpack
/
lib
/
NormalModuleReplacementPlugin.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (38 loc) · 1.17 KB
Breadcrumbs
webpack
/
lib
/
NormalModuleReplacementPlugin.js
Copy path
File metadata and controls
40 lines (38 loc) · 1.17 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var
path
=
require
(
"path"
)
;
function
NormalModuleReplacementPlugin
(
resourceRegExp
,
newResource
)
{
this
.
resourceRegExp
=
resourceRegExp
;
this
.
newResource
=
newResource
;
}
module
.
exports
=
NormalModuleReplacementPlugin
;
NormalModuleReplacementPlugin
.
prototype
.
apply
=
function
(
compiler
)
{
var
resourceRegExp
=
this
.
resourceRegExp
;
var
newResource
=
this
.
newResource
;
compiler
.
plugin
(
"normal-module-factory"
,
function
(
nmf
)
{
nmf
.
plugin
(
"before-resolve"
,
function
(
result
,
callback
)
{
if
(
!
result
)
return
callback
(
)
;
if
(
resourceRegExp
.
test
(
result
.
request
)
)
{
if
(
typeof
newResource
===
"function"
)
{
newResource
(
result
)
;
}
else
{
result
.
request
=
newResource
;
}
}
return
callback
(
null
,
result
)
;
}
)
;
nmf
.
plugin
(
"after-resolve"
,
function
(
result
,
callback
)
{
if
(
!
result
)
return
callback
(
)
;
if
(
resourceRegExp
.
test
(
result
.
resource
)
)
{
if
(
typeof
newResource
===
"function"
)
{
newResource
(
result
)
;
}
else
{
result
.
resource
=
path
.
resolve
(
path
.
dirname
(
result
.
resource
)
,
newResource
)
;
}
}
return
callback
(
null
,
result
)
;
}
)
;
}
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL