This chapter will introduces the directory structure of output files and how to control the output directory of different types of files.
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 is a basic directory for output files. By default, the compiled files will be output in the dist
directory of current project.
The most common output files are HTML files, JS files, and CSS files:
static/js
directory,static/css
directory.In addition, JS files and CSS files sometimes generate some related files:
.LICENSE.txt
suffix..map
suffix.In the filename, [name]
represents the entry name corresponding to this file, such as index
, main
. [hash]
is the hash value generated based on the content of the file.
In development mode, Rsbuild stores the build outputs in memory on the dev server by default, rather than writing then to disk. This can reduce the overhead of fs operations. You can refer to View Static Assets to view all static assets generated in the current build.
You can choose to write the output files to disk, which is typically used for inspecting the contents of the build artifacts or configuring proxy rules for static assets.
Just set the dev.writeToDisk configuration to true
:
Rsbuild provides some configs to modify the directory or filename, you can:
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 uniformly input these static assets into a directory, for example, output to the assets
directory:
The above config produces 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. And 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:
Sometimes you don't want the dist directory to have too many levels, you can set the directory to an empty string to flatten the generated directory.
See the example below:
The above config produces the following directory structure: