'ascii' | 'utf8'
'utf8'
The charset
config allows you to specify the character encoding for output files to ensure they are displayed correctly in different environments.
By default, the output of Rsbuild is encoded in UTF-8, which is the most commonly used character encoding in web applications.
When your web server returns the resource, please ensure that it sends the correct Content-Type response header so that the browser can parse it correctly.
If you want the output files to use ASCII encoding, you can set this in the config file like this:
When using ASCII encoding, all non-ASCII characters are escaped with backslashes, which may make the files slightly larger and harder to read.
Currently, the charset
option only affects files compiled with SWC, which by default includes JavaScript and TypeScript files. However, HTML and CSS files are not affected by the charset
option.
For HTML files, Rsbuild adds a <meta charset="utf-8">
tag by default. You can change this using the html.meta option.