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

@ -97,8 +97,7 @@ const createESMBrowserBuild = async () => {
// );
// });
const rawConfig = {
entryPoints: ["index.tsx"],
const rawConfigCommon = {
bundle: true,
format: "esm",
plugins: [sassPlugin()],
@ -107,28 +106,55 @@ const rawConfig = {
".woff2": "file",
},
packages: "external",
// chunks are always external, so they are not bundled within and get build separately
external: ["*.chunk"],
};
const createESMRawBuild = async () => {
// Development unminified build with source maps
await build({
...rawConfig,
const rawConfigIndex = {
...rawConfigCommon,
entryPoints: ["index.tsx"],
};
const rawConfigChunks = {
...rawConfigCommon,
// create a separate chunk for each
entryPoints: ["**/*.chunk.ts"],
};
function buildDev(chunkConfig) {
const config = {
...chunkConfig,
sourcemap: true,
outdir: "dist/dev",
define: {
"import.meta.env": JSON.stringify({ DEV: true }),
},
});
outdir: "dist/dev",
};
// production minified build without sourcemaps
await build({
...rawConfig,
return build(config);
}
function buildProd(chunkConfig) {
const config = {
...chunkConfig,
minify: true,
outdir: "dist/prod",
define: {
"import.meta.env": JSON.stringify({ PROD: true }),
},
});
outdir: "dist/prod",
};
return build(config);
}
const createESMRawBuild = async () => {
// development unminified build with source maps
await buildDev(rawConfigIndex);
await buildDev(rawConfigChunks);
// production minified buld without sourcemaps
await buildProd(rawConfigIndex);
await buildProd(rawConfigChunks);
};
createESMRawBuild();