Skip to content

Commit

Permalink
WIP NG
Browse files Browse the repository at this point in the history
  • Loading branch information
JRaspass committed Aug 22, 2019
1 parent 67d85d0 commit 3af29a6
Show file tree
Hide file tree
Showing 58 changed files with 1,550 additions and 12,576 deletions.
28 changes: 14 additions & 14 deletions assets/build
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ GO

my ( %data, %paths );

for ( (my $w = 'assets/twemoji.woff2'), <assets/*.{css,ico,js}> ) {
for (
sort { $b =~ /\.woff2/ <=> $a =~ /\.woff2/ or $a cmp $b }
<assets/*.{css,ico,js,woff2}>
) {
say;

my $data = slurp($_);
Expand All @@ -40,17 +43,20 @@ for ( (my $w = 'assets/twemoji.woff2'), <assets/*.{css,ico,js}> ) {

print $fh <<'GO';
case "/favicon.ico":
w.Header().Set("Content-Type", "image/x-icon")
w.Write(faviconIco)
GO

next;
}
elsif ( $_ eq 'twemoji.woff2' ) {
elsif ( $_ eq 'font.woff2' ) {
$data{$name} = $data;
my $path = $paths{$name} = '/assets/' . md5_base64($data) =~ y|+/|-_|r;

print $fh <<GO;
case "$path":
w.Header().Set("Cache-Control", "max-age=9999999,public")
w.Header().Set("Content-Type", "font/woff2")
w.Write($name)
GO

Expand All @@ -61,18 +67,12 @@ GO

if (/\.css$/) {
$data =~ s|svg\(([^#]+)(.+)\)|svg($1, $2)|eg;
$data =~ s|twemojiWoff2|$paths{twemojiWoff2}|;
$data =~ s|fontWoff2|$paths{fontWoff2}|;

$data = run($data, 'csso');
}
else {
my @cmd = (
qw(java -jar /closure-compiler.jar),
qw(--assume_function_wrapper --language_out ES_2017),
);

push @cmd, qw(--externs assets/includes/externs.js -O ADVANCED)
if $_ eq 'scores.js';
my @cmd = qw(java -jar /closure-compiler.jar --language_out ES_2017);

$data = run( $data, @cmd );
}
Expand All @@ -91,14 +91,14 @@ GO

print $fh <<GO;
case ${name}Path:
w.Header()["Cache-Control"] = []string{"max-age=9999999,public"}
w.Header()["Content-Type"] = []string{"$mime"}
w.Header().Set("Cache-Control", "max-age=9999999,public")
w.Header().Set("Content-Type", "$mime")
if strings.Contains(r.Header.Get("Accept-Encoding"), "br") {
w.Header()["Content-Encoding"] = []string{"br"}
w.Header().Set("Content-Encoding", "br")
w.Write(${name}Br)
} else {
w.Header()["Content-Encoding"] = []string{"gzip"}
w.Header().Set("Content-Encoding", "gzip")
w.Write(${name}Gz)
}
GO
Expand Down

0 comments on commit 3af29a6

Please sign in to comment.