Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

This snowpack plugin adds a content hash to your referenced scripts and stylesheets in html files.

License

Notifications You must be signed in to change notification settings

focus-shift/snowpack-plugin-cache-bust

Repository files navigation

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

snowpack-plugin-cache-bust

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.

Usage

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"
  ],
}

Example

<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>

Plugin options

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.

About

This snowpack plugin adds a content hash to your referenced scripts and stylesheets in html files.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •