'ascii' | 'utf8'
'utf8'
The charset
config sets the character encoding for output files, ensuring they display correctly across different environments.
By default, Rsbuild outputs files encoded in UTF-8, the most common character encoding for web applications.
When your web server returns resources, ensure it sends the correct Content-Type response header so browsers can parse them correctly.
To use ASCII encoding for output files, configure it like this:
With ASCII encoding, all non-ASCII characters are escaped with backslashes, making files slightly larger and harder to read.
The charset
option only affects files compiled with SWC, which includes JavaScript and TypeScript files by default. HTML and CSS files are not affected by this option.
For HTML files, Rsbuild adds a <meta charset="utf-8">
tag by default. You can change this using the html.meta option.