false
Whether to inline output style files (.css files) into HTML with <style>
tags.
When this option is enabled, style files are no longer written to the dist directory and only exist inside the HTML file.
By default, the following output files are generated:
After enabling the output.inlineStyles
option:
The output files of production build will become:
And dist/static/css/style.css
will be inlined in index.html
:
Setting inlineStyles: true
is equivalent to setting inlineStyles.enable to 'auto'
. This indicates that inline styles will only be enabled in production mode.
To inline part of the CSS files, set inlineStyles
to a regular expression that matches the URL of the CSS file that needs to be inlined.
For example, to inline main.css
into HTML, add the following configuration:
The production filename includes a hash value by default, such as static/css/main.18a568e5.css
. Therefore, in regular expressions, \w+
is used to match the hash.
Set output.inlineStyles
to a function that accepts the following parameters:
name
: The filename, such as static/css/main.18a568e5.css
.size
: The file size in bytes.To inline assets smaller than 10 kB, add the following configuration:
boolean | 'auto'
false
Whether to enable the inline styles feature. If set to 'auto'
, it will be enabled when the mode
is 'production'
.
RegExp | ((params: { size: number; name: string }) => boolean)
The regular expression or function to match the CSS files that need to be inlined.