|
| 1 | +import { RsbuildDocBadge } from '@components/RsbuildDocBadge'; |
| 2 | + |
1 | 3 | # output
|
| 4 | + |
| 5 | +Configure the build outputs. |
| 6 | + |
| 7 | +{/* ## output.assetPrefix <RsbuildDocBadge path="/config/output/asset-prefix" text="output.assetPrefix" /> */} |
| 8 | + |
| 9 | +{/* In [production mode](https://rsbuild.dev/config/mode), use this option to set the URL prefix for static assets, such as setting it to a CDN URL. */} |
| 10 | + |
| 11 | +## output.charset <RsbuildDocBadge path="/config/output/charset" text="output.charset" /> |
| 12 | + |
| 13 | +The `charset` config allows you to specify the [character encoding](https://developer.mozilla.org/en-US/docs/Glossary/Character_encoding) for output files to ensure they are displayed correctly in different environments. |
| 14 | + |
| 15 | +## output.cleanDistPath <RsbuildDocBadge path="/config/output/clean-dist-path" text="output.cleanDistPath" /> |
| 16 | + |
| 17 | +Whether to clean up all files under the output directory before the build starts (the output directory defaults to `dist`). |
| 18 | + |
| 19 | +## output.copy <RsbuildDocBadge path="/config/output/copy" text="output.copy" /> |
| 20 | + |
| 21 | +Copies the specified file or directory to the dist directory, implemented based on [rspack.CopyRspackPlugin](https://rspack.dev/plugins/rspack/copy-rspack-plugin). |
| 22 | + |
| 23 | +## output.cssModules <RsbuildDocBadge path="/config/output/css-modules" text="output.cssModules" /> |
| 24 | + |
| 25 | +For custom CSS Modules configuration. |
| 26 | + |
| 27 | +## output.dataUriLimit <RsbuildDocBadge path="/config/output/data-uri-limit" text="output.dataUriLimit" /> |
| 28 | + |
| 29 | +Set the size threshold to inline static assets such as images and fonts. |
| 30 | + |
| 31 | +## output.distPath <RsbuildDocBadge path="/config/output/dist-path" text="output.distPath" /> |
| 32 | + |
| 33 | +Set the directory of the dist files. Rsbuild will output files to the corresponding subdirectory according to the file type. |
| 34 | + |
| 35 | +{/* ## output.emitAssets <RsbuildDocBadge path="/config/output/emit-assets" text="output.emitAssets" /> */} |
| 36 | + |
| 37 | +{/* Control whether to emit static assets such as images, fonts, audio, video, etc. */} |
| 38 | + |
| 39 | +## output.emitCss <RsbuildDocBadge path="/config/output/emit-css" text="output.emitCss" /> |
| 40 | + |
| 41 | +Whether to emit CSS to the output bundles. |
| 42 | + |
| 43 | +## output.externals <RsbuildDocBadge path="/config/output/externals" text="output.externals" /> |
| 44 | + |
| 45 | +At build time, prevent some `import` dependencies from being packed into bundles in your code, and instead fetch them externally at runtime. |
| 46 | + |
| 47 | +It is important to note that `output.externals` differs from [source.alias](/config/rsbuild/source#sourcealias). Check out [source.alias](/config/rsbuild/source#sourcealias) documentation for more information. |
| 48 | + |
| 49 | +## output.filenameHash <RsbuildDocBadge path="/config/output/filename-hash" text="output.filenameHash" /> |
| 50 | + |
| 51 | +Whether to add a hash value to the filename after the production build. |
| 52 | + |
| 53 | +## output.filename <RsbuildDocBadge path="/config/output/filename" text="output.filename" /> |
| 54 | + |
| 55 | +Sets the filename of dist files. |
| 56 | + |
| 57 | +{/* ## output.injectStyles <RsbuildDocBadge path="/config/output/inject-styles" text="output.injectStyles" /> */} |
| 58 | + |
| 59 | +{/* Whether to inject styles into DOM. */} |
| 60 | + |
| 61 | +## output.inlineScripts <RsbuildDocBadge path="/config/output/inline-scripts" text="output.inlineScripts" /> |
| 62 | + |
| 63 | +Whether to inline output scripts files (.js files) into HTML with `<script>` tags. |
| 64 | + |
| 65 | +## output.inlineStyles <RsbuildDocBadge path="/config/output/inline-styles" text="output.inlineStyles" /> |
| 66 | + |
| 67 | +Whether to inline output style files (.css files) into HTML with `<style>` tags. |
| 68 | + |
| 69 | +## output.legalComments <RsbuildDocBadge path="/config/output/legal-comments" text="output.legalComments" /> |
| 70 | + |
| 71 | +Configure how to handle the legal comment. |
| 72 | + |
| 73 | +## output.manifest <RsbuildDocBadge path="/config/output/manifest" text="output.manifest" /> |
| 74 | + |
| 75 | +Whether to generate a manifest file that contains information of all assets, and the mapping relationship between [entry module](https://rsbuild.dev/config/source/entry) and assets. |
| 76 | + |
| 77 | +## output.minify <RsbuildDocBadge path="/config/output/minify" text="output.minify" /> |
| 78 | + |
| 79 | +Configure whether to enable code minification in production mode, or to configure minimizer options. |
| 80 | + |
| 81 | +## output.overrideBrowserslist <RsbuildDocBadge path="/config/output/override-browserslist" text="output.overrideBrowserslist" /> |
| 82 | + |
| 83 | +Specifies the range of target browsers that the project is compatible with. |
| 84 | + |
| 85 | +## output.polyfill <RsbuildDocBadge path="/config/output/polyfill" text="output.polyfill" /> |
| 86 | + |
| 87 | +Through the `output.polyfill` option, you can control the injection mode of the polyfills. |
| 88 | + |
| 89 | +:::warning |
| 90 | +Rsbuild's `output.polyfill` injects polyfills into the global scope, which can unexpectedly modify global variables for library consumers. For a non-global polyfill solution for browsers, please refer to [Polyfill - Browser](/guide/advanced/output-compatibility#browser). |
| 91 | +::: |
| 92 | + |
| 93 | +## output.sourceMap <RsbuildDocBadge path="/config/output/source-map" text="output.sourceMap" /> |
| 94 | + |
| 95 | +Used to set whether to generate source map files, and which format of source map to generate. |
| 96 | + |
| 97 | +## output.target <RsbuildDocBadge path="/config/output/target" text="output.target" /> |
| 98 | + |
| 99 | +Setting the build target of Rsbuild. |
| 100 | + |
| 101 | +:::info |
| 102 | +Check out the [Solution](/guide/solution) to learn more about the build target. |
| 103 | +::: |
0 commit comments