Skip to content

Commit

Permalink
chore: use "kB" everywhere with the correct definition (#14061)
Browse files Browse the repository at this point in the history
  • Loading branch information
naruaway committed Aug 21, 2023
1 parent fd9a2cc commit f97ef58
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/config/build-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Specify the directory to nest generated assets under (relative to `build.outDir`
## build.assetsInlineLimit
- **Type:** `number`
- **Default:** `4096` (4kb)
- **Default:** `4096` (4 KiB)
Imported or referenced assets that are smaller than this threshold will be inlined as base64 URLs to avoid extra http requests. Set to `0` to disable inlining altogether.
Expand Down Expand Up @@ -236,7 +236,7 @@ Enable/disable gzip-compressed size reporting. Compressing large output files ca
- **Type:** `number`
- **Default:** `500`
Limit for chunk size warnings (in kbs). It is compared against the uncompressed chunk size as the [JavaScript size itself is related to the execution time](https://v8.dev/blog/cost-of-javascript-2019).
Limit for chunk size warnings (in kB). It is compared against the uncompressed chunk size as the [JavaScript size itself is related to the execution time](https://v8.dev/blog/cost-of-javascript-2019).
## build.watch
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ Running `vite build` with this config uses a Rollup preset that is oriented towa
```
$ vite build
building for production...
dist/my-lib.js 0.08 KiB / gzip: 0.07 KiB
dist/my-lib.umd.cjs 0.30 KiB / gzip: 0.16 KiB
dist/my-lib.js 0.08 kB / gzip: 0.07 kB
dist/my-lib.umd.cjs 0.30 kB / gzip: 0.16 kB
```

Recommended `package.json` for your lib:
Expand Down
8 changes: 4 additions & 4 deletions packages/vite/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function createCjsConfig(isProduction: boolean) {
...Object.keys(pkg.dependencies),
...(isProduction ? [] : Object.keys(pkg.devDependencies)),
],
plugins: [...createNodePlugins(false, false, false), bundleSizeLimit(120)],
plugins: [...createNodePlugins(false, false, false), bundleSizeLimit(123)],
})
}

Expand Down Expand Up @@ -317,7 +317,7 @@ const __require = require;
/**
* Guard the bundle size
*
* @param limit size in KB
* @param limit size in kB
*/
function bundleSizeLimit(limit: number): Plugin {
return {
Expand All @@ -329,10 +329,10 @@ function bundleSizeLimit(limit: number): Plugin {
.join(''),
'utf-8',
)
const kb = size / 1024
const kb = size / 1000
if (kb > limit) {
throw new Error(
`Bundle size exceeded ${limit}kb, current size is ${kb.toFixed(
`Bundle size exceeded ${limit} kB, current size is ${kb.toFixed(
2,
)}kb.`,
)
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export interface BuildOptions {
assetsDir?: string
/**
* Static asset files smaller than this number (in bytes) will be inlined as
* base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
* base64 strings. Default limit is `4096` (4 KiB). Set to `0` to disable.
* @default 4096
*/
assetsInlineLimit?: number
Expand Down Expand Up @@ -234,7 +234,7 @@ export interface BuildOptions {
*/
reportCompressedSize?: boolean
/**
* Adjust chunk size warning limit (in kbs).
* Adjust chunk size warning limit (in kB).
* @default 500
*/
chunkSizeWarningLimit?: number
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
) {
config.logger.warn(
colors.yellow(
`\n(!) Some chunks are larger than ${chunkLimit} kBs after minification. Consider:\n` +
`\n(!) Some chunks are larger than ${chunkLimit} kB after minification. Consider:\n` +
`- Using dynamic import() to code-split the application\n` +
`- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks\n` +
`- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.`,
Expand Down
2 changes: 1 addition & 1 deletion playground/assets/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineConfig({
assetsInclude: ['**/*.unknown'],
build: {
outDir: 'dist/foo',
assetsInlineLimit: 8192, // 8kb
assetsInlineLimit: 8000, // 8 kB
manifest: true,
watch: {},
},
Expand Down

0 comments on commit f97ef58

Please sign in to comment.