false
Whether to inline output scripts files (.js files) into HTML with <script>
tags in production mode.
Note that, with this option on, the scripts files will no longer be written in dist directory, they will only exist inside the HTML file instead.
When using convention-based routing, you need to set output.splitRouteChunks to false if this option is turned on.
By default, we have following output files:
After turn on the output.enableInlineScripts
option:
The output files will become:
And dist/static/js/main.js
will be inlined in index.html
:
If you need to inline part of the JS files, you can set enableInlineScripts
to a regular expression that matches the URL of the JS file that needs to be inlined.
For example, to inline main.js
into HTML, you can add the following configuration:
The production filename includes a hash value by default, such as static/js/main.18a568e5.js
. Therefore, in regular expressions, \w+
is used to match the hash.
You can also set output.enableInlineScripts
to a function that accepts the following parameters:
name
: The filename, such as static/js/main.18a568e5.js
.size
: The file size in bytes.For example, if we want to inline assets that are smaller than 10KB, we can add the following configuration: