better build process, caching fixes

This commit is contained in:
koehr 2020-11-22 20:49:17 +01:00
parent c9f817a676
commit 3b5b233b06
9 changed files with 116 additions and 1391 deletions

View file

@ -14,6 +14,8 @@
"chalk": "^4.1.0", "chalk": "^4.1.0",
"phantomas": "^2.0.0", "phantomas": "^2.0.0",
"rollup": "^2.3.4", "rollup": "^2.3.4",
"rollup-plugin-app-utils": "^1.0.6",
"rollup-plugin-hash": "^1.3.0",
"rollup-plugin-livereload": "^2.0.0", "rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^6.0.0", "rollup-plugin-svelte": "^6.0.0",
"rollup-plugin-terser": "^7.0.0", "rollup-plugin-terser": "^7.0.0",

View file

@ -1,2 +0,0 @@
/*# sourceMappingURL=bundle.css.map */

View file

@ -1,8 +0,0 @@
{
"version": 3,
"file": "bundle.css",
"sources": [],
"sourcesContent": [],
"names": [],
"mappings": ""
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6,8 +6,8 @@
<title>The 250kb Club</title> <title>The 250kb Club</title>
<meta name="description" content="An exclusive membership for web pages presenting themselves in no more than 250kb."> <meta name="description" content="An exclusive membership for web pages presenting themselves in no more than 250kb.">
<link rel="icon" href="/favicon.png" type="image/x-icon"> <link rel="icon" href="/favicon.png" type="image/x-icon">
<link rel='stylesheet' href='/global.css'> <link rel='stylesheet' href='/global.css?1606074523572'>
<script defer src='/build/bundle.js'></script> <script defer src='/build/bundle.js?1606074523572'></script>
</head> </head>
<body> <body>
<header> <header>

View file

@ -1,31 +1,33 @@
import svelte from 'rollup-plugin-svelte'; import svelte from 'rollup-plugin-svelte'
import resolve from '@rollup/plugin-node-resolve'; import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'; import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'; import json from '@rollup/plugin-json'
import livereload from 'rollup-plugin-livereload'; import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'; import { terser } from 'rollup-plugin-terser'
import { emptyDirectories, htmlInjector } from 'rollup-plugin-app-utils'
const isProduction = !process.env.ROLLUP_WATCH; const isProduction = !process.env.ROLLUP_WATCH
const timeStamp = Date.now()
function serve() { function serve() {
let server; let server
function toExit() { function toExit() {
if (server) server.kill(0); if (server) server.kill(0)
} }
return { return {
writeBundle() { writeBundle() {
if (server) return; if (server) return
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'], stdio: ['ignore', 'inherit', 'inherit'],
shell: true shell: true
}); })
process.on('SIGTERM', toExit); process.on('SIGTERM', toExit)
process.on('exit', toExit); process.on('exit', toExit)
} }
}; }
} }
export default { export default {
@ -37,14 +39,15 @@ export default {
file: 'public/build/bundle.js' file: 'public/build/bundle.js'
}, },
plugins: [ plugins: [
emptyDirectories('./public/build/'),
svelte({ svelte({
// enable run-time checks when not in production // enable run-time checks when not in production
dev: !isProduction, dev: !isProduction,
// we'll extract any component CSS out into // we'll extract any component CSS out into
// a separate file - better for performance // a separate file - better for performance
css: css => { // css: css => {
css.write('bundle.css'); // css.write('bundle.css')
} //}
}), }),
// If you have external dependencies installed from // If you have external dependencies installed from
@ -58,6 +61,12 @@ export default {
}), }),
commonjs(), commonjs(),
htmlInjector({
template: './src/template.html',
target: './public/index.html',
injects: { timeStamp },
}),
json({ json({
exclude: ['node_modules/**'], exclude: ['node_modules/**'],
preferConst: true, preferConst: true,
@ -80,4 +89,4 @@ export default {
watch: { watch: {
clearScreen: false clearScreen: false
} }
}; }

39
src/template.html Normal file
View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The 250kb Club</title>
<meta name="description" content="An exclusive membership for web pages presenting themselves in no more than 250kb.">
<link rel="icon" href="/favicon.png" type="image/x-icon">
<link rel='stylesheet' href='/global.css?{timeStamp}'>
<script defer src='/build/bundle.js?{timeStamp}'></script>
</head>
<body>
<header>
<h1>The 250kb&nbsp;Club</h1>
<p>
The WWW has become a bloated mess. Many pages are loading megabytes of Javascript to show you a few kilobytes of content.
These things are a <strong>cancerous growth</strong> on the web that we should stand up against.
</p>
<p>We can make a difference - no matter how small it may seem. The <em>250kb Club</em> is a collection of web pages that focus on performance, efficiency and accessibility.</p>
<p>
If you'd like to suggest a web page to add to this collection,
<a href="https://github.com/nkoehring/250kb-club" rel="noopener" target="_blank">open a pull request or a ticket in the official Github repository</a>.
The site will be reviewed and, if applicable, added to the list below.
</p>
<p>If your pages exceeds 250kb, you might consider <a href="https://1MB.club" rel="noopener" target="_blank">1MB.club</a> which is the inspiration for this page.</p>
</header>
<main id="members-table">
</main>
<footer>
<p>
Made with &hearts; for a performant web by <a href="https://koehr.in" rel="noopener" target="_blank">Norman Köhring</a>.
Inspired by <a href="https://uglyduck.ca" rel="noopener" target="_blank">Bradley Taunt</a>s <a href="https://1MB.club" rel="noopener" target="_blank">1MB.club</a>
<br/>
The code of this page is open source. You can <a href="https://github.com/nkoehring/250kb-club" rel="noopener" target="_blank">find&nbsp;it&nbsp;on&nbsp;Github</a>.
</p>
</footer>
<script data-goatcounter="https://250kb-club.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
</body>
</html>

View file

@ -349,6 +349,11 @@ console-clear@^1.1.0:
resolved "https://registry.yarnpkg.com/console-clear/-/console-clear-1.1.1.tgz#995e20cbfbf14dd792b672cde387bd128d674bf7" resolved "https://registry.yarnpkg.com/console-clear/-/console-clear-1.1.1.tgz#995e20cbfbf14dd792b672cde387bd128d674bf7"
integrity sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ== integrity sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ==
constants@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/constants/-/constants-0.0.2.tgz#f973bcf3b69b6493b3b3645723124fbabce25094"
integrity sha1-+XO887abZJOzs2RXIxJPurziUJQ=
css-shorthand-properties@^1.1.1: css-shorthand-properties@^1.1.1:
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/css-shorthand-properties/-/css-shorthand-properties-1.1.1.tgz#1c808e63553c283f289f2dd56fcee8f3337bd935" resolved "https://registry.yarnpkg.com/css-shorthand-properties/-/css-shorthand-properties-1.1.1.tgz#1c808e63553c283f289f2dd56fcee8f3337bd935"
@ -533,6 +538,14 @@ has@^1.0.3:
dependencies: dependencies:
function-bind "^1.1.1" function-bind "^1.1.1"
hasha@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1"
integrity sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=
dependencies:
is-stream "^1.0.1"
pinkie-promise "^2.0.0"
http-proxy-agent@^4.0.1: http-proxy-agent@^4.0.1:
version "4.0.1" version "4.0.1"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz#8a8c8ef7f5932ccf953c296ca8291b95aa74aa3a" resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz#8a8c8ef7f5932ccf953c296ca8291b95aa74aa3a"
@ -611,6 +624,11 @@ is-reference@^1.1.2:
dependencies: dependencies:
"@types/estree" "*" "@types/estree" "*"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ=
jest-worker@^26.2.1: jest-worker@^26.2.1:
version "26.6.2" version "26.6.2"
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed"
@ -797,6 +815,18 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
pinkie-promise@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o=
dependencies:
pinkie "^2.0.0"
pinkie@^2.0.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA=
pkg-dir@^4.2.0: pkg-dir@^4.2.0:
version "4.2.0" version "4.2.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3"
@ -883,6 +913,20 @@ rimraf@^3.0.2:
dependencies: dependencies:
glob "^7.1.3" glob "^7.1.3"
rollup-plugin-app-utils@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/rollup-plugin-app-utils/-/rollup-plugin-app-utils-1.0.6.tgz#e75b1e5343bfaf9ed797d53e5f122a10e2580fb4"
integrity sha512-6UEaAEMgOK/H9Hqvcf+WbEa9QFypHJoD23QYEYqh9pK7aOXQdzs/QBhPjf/cGxvccYn1QL/OqqNXiCKRskcerw==
dependencies:
constants "0.0.2"
rollup-plugin-hash@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-hash/-/rollup-plugin-hash-1.3.0.tgz#6f87442cb432a8bf45356855fec69aab5dc22b07"
integrity sha512-a/DUrOlXOqCpwCF+dPXEPDlqbOMkfXDWEWOeVU2bhrW18Dbh0nu2JLLrS3FIiasVrDZhoxhwhSkV/dg15gwPyw==
dependencies:
hasha "^2.2.0"
rollup-plugin-livereload@^2.0.0: rollup-plugin-livereload@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-livereload/-/rollup-plugin-livereload-2.0.0.tgz#d3928d74e8cf2ae4286c5dd46b770fd3f3b82313" resolved "https://registry.yarnpkg.com/rollup-plugin-livereload/-/rollup-plugin-livereload-2.0.0.tgz#d3928d74e8cf2ae4286c5dd46b770fd3f3b82313"