This section introduces the output file directory structure and explains how to control the output directory for different file types.
If you want to know how to deploy the build outputs of Rsbuild as a static site, please refer to Deploy Static Site.
The default output directory structure is shown below. Output files are written to the dist
directory in the current project.
The most common output files are HTML, JS, and CSS files:
static/js
directory by default.static/css
directory by default.Additional files may be generated alongside JS and CSS files:
.LICENSE.txt
suffix..map
suffix.In the filename, [name]
represents the entry name for this file, such as index
or main
. [hash]
is a hash value generated based on the file content.
In development mode, Rsbuild stores build outputs in memory on the dev server by default, rather than writing them to disk. This reduces filesystem operation overhead. Refer to View Static Assets to see all static assets generated in the current build.
To write output files to disk (typically used for inspecting build artifacts or configuring proxy rules for static assets), set the dev.writeToDisk configuration to true
:
Rsbuild provides several configuration options to modify the directory or filename:
When importing static assets such as images, SVG, fonts, media, etc., in your code, they are written to the dist/static
directory and automatically organized into subdirectories by file type:
Use the output.distPath config to write these static assets to a single directory. For example, to organize them in an assets
directory:
This configuration generates the following directory structure:
When the output.target of Rsbuild is 'node'
, Rsbuild will generate output files for Node.js:
Node.js outputs typically contain only JS files, without HTML or CSS. The JS filenames do not include hash values.
Modify the output path of Node.js files using the environments config.
For example, to write Node.js files to the server
directory:
For a flatter directory structure, set any directory to an empty string to flatten the generated output structure.
Here's an example:
This configuration will generate the following directory structure: