This section introduces the output file directory structure and 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 following section shows the basic output file directory structure. By default, compiled files are output to the dist
directory of the current project.
The most common output files are HTML files, JS files, and CSS files:
static/js
directory by default.static/css
directory by default.Additionally, JS files and CSS files sometimes generate related files:
.LICENSE.txt
suffix..map
suffix.In the filename, [name]
represents the entry name for this file, such as index
or main
. [hash]
is the 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. You can refer to View Static Assets to view all static assets generated in the current build.
You can choose to write output files to disk, which is typically used for inspecting build artifacts or configuring proxy rules for static assets.
Just set the dev.writeToDisk configuration to true
:
Rsbuild provides several configuration options to modify the directory or filename:
When you import static assets such as images, SVG, fonts, media, etc., in the code, they will also be output to the dist/static
directory, and automatically assigned to the corresponding subdirectories according to the file type:
You can use the output.distPath config to output these static assets to a single directory, for example, output to the assets
directory:
The above config will generate the following directory structure:
When the output.target of Rsbuild is 'node'
, Rsbuild will generate output files for Node.js:
Node.js outputs usually only contain JS files, no HTML or CSS. The JS file names will not contain hash.
You can modify the output path of Node.js files via the environments config.
For example, output Node.js files to the server
directory:
If you prefer a flatter directory structure in the dist directory, you can set the directory to an empty string to flatten the generated directory.
Here's an example:
This configuration will generate the following directory structure: