Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Site.js
site
Commits
9ac2bb48
Verified
Commit
9ac2bb48
authored
Jun 09, 2020
by
Aral Balkan
Browse files
Build script is functional again for the new site
parent
9080e311
Changes
3
Hide whitespace changes
Inline
Side-by-side
_build/inline-css-and-js.js
View file @
9ac2bb48
...
...
@@ -10,7 +10,27 @@ const fs = require('fs')
let
index
=
fs
.
readFileSync
(
'
index.html
'
,
'
utf-8
'
)
const
styles
=
fs
.
readFileSync
(
'
tmp/styles.css
'
,
'
utf-8
'
)
const
scripts
=
fs
.
readFileSync
(
'
tmp/scripts.js
'
,
'
utf-8
'
)
// Note: the odd-looking replace is necessary because, after 24 years of using JavaScript, I just discovered
// ===== that string.replace is actually broken. Its default behaviour is to use dollar-denoted patterns in
// the replacement script to affect replacement behaviour. Until now, I was not bitten by this. What it
// means is, if you’re loading in content you don’t necessarily control and it has the dollar-denoted
// patterns in it, your replacement will not work as you thought it would. In this case, it broke on:
//
// const $ = document.querySelector.bind(document)
// const $$ = document.querySelectorAll.bind(document)
//
// The code after the replacement (without the hack below) would read:
//
// const $ = document.querySelector.bind(document)
// const $ = document.querySelectorAll.bind(document)
//
// This, of course, would then throw a JavaScript error.
//
// The way replace() should be designed is to default to not using patterns in the replacement string
// unless specifically told to do so.
//
const
scripts
=
fs
.
readFileSync
(
'
tmp/scripts.js
'
,
'
utf-8
'
).
replace
(
/
\$
/g
,
'
$$$$
'
)
index
=
index
.
replace
(
/<
\!
-- Start: styles -->.*
?
<
\!
-- End: styles -->/
s
,
`<style>
${
styles
}
</style>`
)
index
=
index
.
replace
(
/<
\!
-- Start: scripts -->.*
?
<
\!
-- End: scripts -->/
s
,
`<script>
${
scripts
}
</script>`
)
...
...
_build/inline-svg.js
View file @
9ac2bb48
...
...
@@ -13,8 +13,6 @@ const fs = require('fs')
let
index
=
fs
.
readFileSync
(
'
../tmp/index-minified.html
'
,
'
utf8
'
)
console
.
log
(
index
)
const
emoji
=
fs
.
readdirSync
(
'
../images/emoji
'
).
map
(
f
=>
`../images/emoji/
${
f
}
`
)
const
illustrations
=
fs
.
readdirSync
(
'
../images/illustrations
'
).
map
(
f
=>
`/images/illustrations/
${
f
}
`
)
...
...
build
View file @
9ac2bb48
...
...
@@ -12,10 +12,12 @@ mkdir dist
# CSS (temporary; to be collated into index later).
echo
" > Minify CSS"
minify
css
/
highlight
.
js
/
github
.
css
>>
tmp
/
styles
.
css
minify
css
/
index
.
css
>>
tmp
/
styles
.
css
# JS (temporary; to be collated into index later).
echo
" > Minify JS"
minify
js
/
highlight
.
pack
.
js
>>
tmp
/
scripts
.
js
minify
js
/
index
.
js
>>
tmp
/
scripts
.
js
# Inline the CSS and JS into the HTML.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment