FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
MyNovelReader/rollup-plugin-compress.js at master · frederickgithub/MyNovelReader · GitHub
frederickgithub
MyNovelReader
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
MyNovelReader
/
rollup-plugin-compress.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (27 loc) · 775 Bytes
Breadcrumbs
MyNovelReader
/
rollup-plugin-compress.js
Copy path
File metadata and controls
30 lines (27 loc) · 775 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
28
29
30
import
{
minify
}
from
'terser'
import
{
createFilter
}
from
'@rollup/pluginutils'
export
default
function
compress
(
opts
=
{
}
)
{
const
type
=
opts
.
type
?.
toLowerCase
(
)
||
'js'
const
filter
=
createFilter
(
opts
.
targets
)
const
minifyOpts
=
{
mangle
:
false
,
compress
:
{
defaults
:
false
}
}
let
transform
if
(
type
===
'js'
)
{
transform
=
async
function
(
code
,
id
)
{
if
(
filter
(
id
)
)
{
return
await
minify
(
code
,
minifyOpts
)
}
}
}
else
if
(
type
===
'json'
)
{
transform
=
async
function
(
code
,
id
)
{
if
(
filter
(
id
)
)
{
return
JSON
.
stringify
(
JSON
.
parse
(
code
)
)
}
}
}
else
{
throw
new
Error
(
`unknown file type
${
type
}
. 未知的文件类型
${
type
}
。`
)
}
return
{
name
:
'compress'
,
transform
}
}
Back
|
FazBrowse Home
|
New Git URL