Skip to content

Commit 7c843c1

Browse files
committed
Refactor favicon generator to be an Astro integration, remove circular dependencies from ClientScriptError tool chain
1 parent a8c6e32 commit 7c843c1

12 files changed

Lines changed: 855 additions & 435 deletions

File tree

‎astro.config.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ import {
2020
environmentalVariablesConfig,
2121
getSentryAuthToken,
2222
getSiteUrl,
23+
isUnitTest,
2324
isVercel,
2425
markdownConfig,
2526
serviceWorkerConfig,
2627
vercelConfig,
2728
} from './src/lib/config'
2829
import { callToActionValidator } from './src/integrations/CtaValidator'
30+
import { faviconGenerator } from './src/integrations/FaviconGenerator'
31+
import { packageRelease } from './src/integrations/PackageRelease'
2932
import { privacyPolicyVersion } from './src/integrations/PrivacyPolicyVersion'
3033
import { createSerializeFunction, pagesJsonWriter } from './src/integrations/sitemapSerialize'
3134

@@ -35,16 +38,27 @@ export default defineConfig({
3538
enabled: false,
3639
},
3740
env: environmentalVariablesConfig,
38-
integrations: [
41+
/**
42+
* Astro sets substantial Vite config internally in the framework. When you use Vitest
43+
* in an Astro project, you use Astro's getViteConfig helper to get the resolved internal
44+
* Vite syntax along with any Vite syntax set in this astro.config.ts file. Since integrations
45+
* can change config, they're ran when the helper's called. This causes problems for
46+
* unit testing integrations.
47+
*/
48+
integrations: isUnitTest() ? [] : [
3949
AstroPWA(serviceWorkerConfig),
4050
icon(),
4151
mdx(markdownConfig),
4252
preact({ devtools: true }),
53+
/** Generate favicons and PWA icons from source SVG */
54+
faviconGenerator(),
4355
/** Verify number of call to actions included in Markdown files */
4456
callToActionValidator({
4557
/** Enable debug logging to see validation details */
4658
debug: true
4759
}),
60+
/** Inject package release (name@version) for tracking regressions between releases */
61+
packageRelease(),
4862
/** Inject privacy policy version from git commit date for GDPR record keeping */
4963
privacyPolicyVersion(),
5064
/** Only include Sentry integration in Vercel environments */

‎package.json‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
"not IE 11"
2727
],
2828
"scripts": {
29-
"build": "cross-env NODE_ENV=production npm run build:favicons && npx astro build",
30-
"build:dev": "cross-env NODE_ENV=development npm run build:favicons && npx astro build",
31-
"build:favicons": "npx ts-node ./scripts/build/favicon.ts",
29+
"build": "cross-env NODE_ENV=production npx astro build",
30+
"build:dev": "cross-env NODE_ENV=development npx astro build",
3231
"check": "npx astro check",
3332
"clean": "npx rimraf dist && npx rimraf .astro",
34-
"dev": "npm run sync && npm run build:favicons && cross-env NODE_ENV=development npx vercel dev",
33+
"dev": "npm run sync && cross-env NODE_ENV=development npx vercel dev",
3534
"format": "npm run format:json && npm run format:code && npm run format:style",
3635
"format:code": "npx prettier --write \"@types/**/*.{js,ts}\" \"scripts/**/*.{js,ts}\" \"src/**/*.{js,ts,tsx,astro}\" --plugin=prettier-plugin-astro",
3736
"format:json": "npx prettier --write '**/*.json' --cache --ignore-path .gitignore",
@@ -40,7 +39,7 @@
4039
"lint:code": "npx eslint \"@types/**/*.{js,ts}\" \"scripts/**/*.{js,ts}\" \"src/**/*.{js,ts,tsx,astro}\"",
4140
"lint:json": "npx prettier --write '**/*.json' --cache --ignore-path .gitignore",
4241
"lint:style": "npx stylelint \"src/**/*.{css,astro}\"",
43-
"preview": "npm run build:favicons && npx astro build && astro preview",
42+
"preview": "npx astro build && astro preview",
4443
"sync": "npx astro sync",
4544
"test": "npm run test:unit && npm run test:e2e",
4645
"test:coverage": "npx vitest run --coverage",
@@ -103,7 +102,6 @@
103102
"tailwindcss": "^4.1.16",
104103
"title-case": "4.3.2",
105104
"to-ico": "1.1.5",
106-
"ts-node": "10.9.2",
107105
"uuid": "^13.0.0",
108106
"vite": "^7.1.12",
109107
"workbox-build": "7.3.0",

‎scripts/build/__tests__/favicon.spec.ts‎

Lines changed: 0 additions & 299 deletions
This file was deleted.

0 commit comments

Comments
 (0)