FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
tutorial/webpack/webpackGenStatsPlugin.js at master · universal-react/tutorial · GitHub
universal-react
/
tutorial
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
tutorial
/
webpack
/
webpackGenStatsPlugin.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (24 loc) · 859 Bytes
Breadcrumbs
tutorial
/
webpack
/
webpackGenStatsPlugin.js
Copy path
File metadata and controls
27 lines (24 loc) · 859 Bytes
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
const
fs
=
require
(
'fs'
)
;
const
path
=
require
(
'path'
)
;
/**
* transfer stats to json
*
@param
{
object
} options.path generate file path
* finally the webpack-stats.json should like this: { statsJson: WEBPACK_STATS_OBJ }
*/
function
WebpackGenStatsPlugin
(
options
)
{
this
.
options
=
Object
.
assign
(
{
}
,
options
,
{
path
:
''
}
)
;
}
WebpackGenStatsPlugin
.
prototype
.
apply
=
function
(
compiler
)
{
compiler
.
plugin
(
'done'
,
stats
=>
{
const
statsJson
=
stats
.
toJson
(
)
;
const
statsStr
=
JSON
.
stringify
(
{
statsJson
}
)
;
const
fileName
=
'webpack-stats.json'
;
const
filePath
=
this
.
options
.
path
?
path
.
join
(
this
.
options
.
path
,
fileName
)
:
path
.
join
(
stats
.
compilation
.
outputOptions
.
path
,
fileName
)
;
fs
.
writeFile
(
filePath
,
statsStr
,
(
err
)
=>
{
if
(
err
)
{
process
.
exit
(
1
)
;
}
}
)
;
}
)
;
}
module
.
exports
=
WebpackGenStatsPlugin
;
Back
|
FazBrowse Home
|
New Git URL