FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gpu.js/scripts/minify.js at develop · gpujs/gpu.js · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
gpujs
/
gpu.js
Public
Notifications
You must be signed in to change notification settings
Fork
663
Star
15.4k
Code
Issues
64
Pull requests
2
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
gpu.js
/
scripts
/
minify.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (40 loc) · 1.57 KB
Breadcrumbs
gpu.js
/
scripts
/
minify.js
Copy path
File metadata and controls
45 lines (40 loc) · 1.57 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
41
42
43
44
45
// Minifies the built bundles. Replaces gulp's `minify`.
const
fs
=
require
(
'fs'
)
;
const
path
=
require
(
'path'
)
;
const
{
minify
:
terserMinify
}
=
require
(
'terser'
)
;
const
{
ROOT
,
write
}
=
require
(
'./lib'
)
;
// ascii_only escapes non-ASCII to \uXXXX. acorn's unicode identifier tables
// are the only source of it here, and leaving those bytes raw broke the bundle
// for anyone serving it without a matching charset (#743, #744).
const
options
=
{
output
:
{
ascii_only
:
true
,
// Keep licence comments, and say so rather than leaning on terser's
// default. The bundle's own banner is one of them: it carries `@license`,
// so it survives minification in place and must not be prepended a second
// time — which is how the minified files ended up with two banners, a
// second apart, for anyone who opened them on a CDN.
comments
:
/
@
l
i
c
e
n
s
e
|
@
p
r
e
s
e
r
v
e
/
,
}
,
}
;
const
targets
=
[
[
'dist/gpu-browser.js'
,
'dist/gpu-browser.min.js'
]
,
[
'dist/gpu-browser-core.js'
,
'dist/gpu-browser-core.min.js'
]
,
]
;
async
function
minify
(
)
{
for
(
const
[
from
,
to
]
of
targets
)
{
const
source
=
fs
.
readFileSync
(
path
.
join
(
ROOT
,
from
)
,
'utf8'
)
;
// the banner comes through from the unminified bundle, so the minified
// file carries the same one -- same version, same timestamp
const
result
=
await
terserMinify
(
{
[
path
.
basename
(
from
)
]
:
source
}
,
options
)
;
if
(
result
.
error
)
throw
result
.
error
;
write
(
to
,
result
.
code
)
;
}
}
if
(
require
.
main
===
module
)
{
minify
(
)
.
catch
(
error
=>
{
console
.
error
(
error
)
;
process
.
exit
(
1
)
;
}
)
;
}
module
.
exports
=
{
minify
}
;
Back
|
FazBrowse Home
|
New Git URL