feat: add first-class support for CJK (#8530)

This commit is contained in:
Marcel Mraz 2024-10-17 21:14:17 +03:00 committed by GitHub
parent 21815fb930
commit b479f3bd65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
288 changed files with 3559 additions and 918 deletions

View file

@ -25,8 +25,14 @@ export default defineConfig({
output: {
assetFileNames(chunkInfo) {
if (chunkInfo?.name?.endsWith(".woff2")) {
// TODO: consider splitting all fonts similar to Xiaolai
// fonts don't change often, so hash is not necessary
// put on root so we are flexible about the CDN path
return "[name]-[hash][extname]";
if (chunkInfo.name.includes("Xiaolai")) {
return "[name][extname]";
} else {
return "[name]-[hash][extname]";
}
}
return "assets/[name]-[hash][extname]";
@ -75,17 +81,21 @@ export default defineConfig({
},
workbox: {
// Don't push fonts, locales and wasm to app precache
globIgnores: ["fonts.css", "**/locales/**", "service-worker.js", "**/*.wasm-*.js"],
// don't precache fonts, locales and separate chunks
globIgnores: ["fonts.css", "**/locales/**", "service-worker.js", "**/*.chunk-*.js"],
runtimeCaching: [
{
urlPattern: new RegExp("/.+.(ttf|woff2|otf)"),
handler: "CacheFirst",
urlPattern: new RegExp(".+.woff2"),
handler: 'CacheFirst',
options: {
cacheName: "fonts",
cacheName: 'fonts',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 90, // <== 90 days
maxEntries: 1000,
maxAgeSeconds: 60 * 60 * 24 * 90, // 90 days
},
cacheableResponse: {
// 0 to cache "opaque" responses from cross-origin requests (i.e. CDN)
statuses: [0, 200],
},
},
},
@ -111,10 +121,10 @@ export default defineConfig({
},
},
{
urlPattern: new RegExp(".wasm-.+.js"),
urlPattern: new RegExp(".chunk-.+.js"),
handler: "CacheFirst",
options: {
cacheName: "wasm",
cacheName: "chunk",
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 90, // <== 90 days