Skip to content

Commit

Permalink
Fine-tune minification and remove unnecessary cache headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro-FA committed Oct 13, 2024
1 parent 003d1a2 commit 895ac09
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
1 change: 1 addition & 0 deletions lib/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum MaterialWindowSizeClass implements Comparable<MaterialWindowSizeClass> {

Future<void> openWebpage(String url) async {
final uri = Uri.parse(url);
assert(uri.scheme == 'https', 'URL must be secure');
if (!await launchUrl(uri)) {
throw Exception('Could not launch $uri');
}
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
"build:html": "flutter build web --no-pub --release --no-web-resources-cdn --web-renderer html",
"build:wasm": "flutter build web --no-pub --release --no-web-resources-cdn --wasm",
"build": "npm run build:${BUILD_RENDERER:-html}",
"postbuild:html": "npm run generate-sitemap -- -o build/web/sitemap.xml && npm run minify",
"postbuild:wasm": "npm run postbuild:html",
"postbuild:html": "npm run generate-sitemap -- -o build/web/sitemap.xml && npm run minify:js",
"postbuild:wasm": "npm run postbuild:html && npm run minify:mjs",
"preserve:release": "npm run build",
"serve:release": "dart run dhttpd --port ${npm_package_config_port} --path build/web/ --headersfile=build/web/_headers",
"serve": "flutter run -d chrome",
"predeploy": "npm run build",
"deploy": "wrangler pages deploy build/web/ --branch=${DEPLOY_BRANCH} --project-name=${npm_package_name}",
"generate-sitemap": "tsx scripts/generate_sitemap.ts lib/pages/*.dart --baseUrl ${npm_package_config_url}",
"generate-routes": "dart run build_runner build",
"minify": "esbuild build/web/*.js --outdir=build/web/ --minify --format=esm --tree-shaking=true --allow-overwrite"
"minify:js": "esbuild 'build/web/**/*.js' --outdir=build/web/ --minify --tree-shaking=true --allow-overwrite",
"minify:mjs": "esbuild 'build/web/**/*.mjs' --outdir=build/web/ --minify --tree-shaking=true --allow-overwrite --out-extension:.js=.mjs"
},
"repository": {
"type": "git",
Expand Down
16 changes: 0 additions & 16 deletions web/_headers
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,3 @@
Content-Security-Policy: script-src 'sha256-jRFbZPGxmdoW0/Eufbok8i1mRwc8cgBguB60B/V1YeU=' 'strict-dynamic' 'wasm-unsafe-eval'; object-src 'none'; base-uri 'self';
Cross-Origin-Embedder-Policy: credentialless
Cross-Origin-Opener-Policy: same-origin

# Cache for 30 days
/icons/*
Cache-Control: public, max-age=2592000

/favicon.png
Cache-Control: public, max-age=2592000

/assets/*
Cache-Control: public, max-age=2592000, must-revalidate

/canvaskit/*
Cache-Control: public, max-age=2592000, must-revalidate

/manifest.json
Cache-Control: public, max-age=2592000, must-revalidate

0 comments on commit 895ac09

Please sign in to comment.