string | string[]
undefined
Add a script before the entry file of each page. This script will be executed before the page code. It can be used to execute global logics, such as injecting polyfills, setting global styles, etc.
First create a src/polyfill.ts
file:
Then configure src/polyfill.ts
to source.preEntry
:
Re-run the compilation and visit any page, you can see that the code in src/polyfill.ts
has been executed, and the I am a polyfill
is logged in the console.
You can also configure the global style through source.preEntry
, this CSS code will be loaded earlier than the page code, such as introducing a normalize.css
file:
You can add multiple scripts by setting preEntry
to an array, and they will be executed in array order: