Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
d5634cfe
Commit
d5634cfe
authored
13 years ago
by
Austin King
Browse files
Options
Downloads
Patches
Plain Diff
A slight tweak on
https://gist.github.com/1849619
cachify CSS while compressing it. Fixes Issue 620
parent
88d35b4e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/compress-worker.js
+18
-1
18 additions, 1 deletion
scripts/compress-worker.js
with
18 additions
and
1 deletion
scripts/compress-worker.js
+
18
−
1
View file @
d5634cfe
const
cachify
=
require
(
'
connect-cachify
'
),
fs
=
require
(
'
fs
'
),
jsp
=
require
(
"
uglify-js
"
).
parser
,
logger
=
require
(
'
../lib/logging.js
'
).
logger
,
pro
=
require
(
"
uglify-js
"
).
uglify
,
uglifycss
=
require
(
'
uglifycss
'
),
mkdirp
=
require
(
'
mkdirp
'
),
...
...
@@ -31,7 +33,8 @@ function compressResource(staticPath, name, files, cb) {
final_code
=
pro
.
split_lines
(
pro
.
gen_code
(
ast
),
32
*
1024
);
// compressed code here
}
else
if
(
/
\.
css$/
.
test
(
name
))
{
// compress css
final_code
=
uglifycss
.
processString
(
orig_code
);
var
cach_code
=
cachify_embedded
(
orig_code
);
final_code
=
uglifycss
.
processString
(
cach_code
);
}
else
{
return
cb
(
"
can't determine content type:
"
+
name
);
}
...
...
@@ -78,6 +81,20 @@ function compressResource(staticPath, name, files, cb) {
isBuildNeeded
();
}
var
static_root
=
path
.
join
(
__dirname
,
'
..
'
,
'
resources/static/
'
);
logger
.
info
(
"
cachify will look in
"
+
static_root
);
// Cachify only used in compress for CSS Images, so no asserts needed
cachify
.
setup
({},
{
root
:
static_root
});
function
cachify_embedded
(
css_src
)
{
return
css_src
.
replace
(
/url
\s
*
\([
'"
](
.*
)\s
*
[
'"
]\s
*
\)
/g
,
function
(
str
,
url
)
{
// This will throw an error if url doesn't exist. This is good as we will
// catch typos during build.
logger
.
info
(
"
For
"
+
str
+
"
making
"
+
url
+
"
into
"
+
cachify
.
cachify
(
url
));
return
"
url('
"
+
cachify
.
cachify
(
url
)
+
"
')
"
;
});
}
process
.
on
(
'
message
'
,
function
(
m
)
{
var
startTime
=
new
Date
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment