Update (April 20, 2022): Snowpack is no longer actively maintained and is not recommended for new projects.
Check out Vite for a well-maintained Snowpack alternative.
See also: esbuild, parcel
This snowpack plugin adds a content hash to your referenced scripts and stylesheets in html files.
The hash is created on optimize
command. So this won't interfere developing with watch mode.
Currently there is no published artifact in the npm registry. You have to add this plugin via github url.
// package.json
{
"devDependencies": {
"snowpack-plugin-cache-bust": "https://github.com/focus-shift/snowpack-plugin-cache-bust.git#<VERSION_TAG>"
}
}
// snowpack.config.js
{
plugins: [
"snowpack-plugin-cache-bust"
],
}
<link rel="stylesheet" href="/css/style.css" />
<script src="/js/app.js"></script>
will become
<link rel="stylesheet" href="/css/style-12345.css" />
<script src="/js/app-abcdefg.js"></script>
snowpack-plugin-cache-bust
can be configured with following options:
// snowpack.config.js
{
plugins: [
["snowpack-plugin-cache-bust", options]
],
}
Name | Type | Description |
---|---|---|
netflify |
boolean |
(default: false) Set this to true if you want a _header file to be created that enables cache-control for netlify. |