sparkbox / cachebust

A simple node cachebust tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Idea: Add option to not generate manifest

patricksimpson opened this issue · comments

A manifest file is generated when replacements have been made. This work is saved within the manifest file. If a user however prefers, this manifest doesn't have to be written. Instead, a manifest could be output to standard output.

This would give the developer the option to redirect the output elsewhere (say, >/dev/null) In some cases this is desired, say on a build server, or in a git versioned repo, there is no reason to keep a manifest since each deploys a copy of the original is retained from the source control.

Hi, loving this tool. Just a suggestion in the README there are the following two statements:

"Added a -n or --no-backup option to cachebust, this will no generate a manifest file. See #9

In some cases this is desired, say on a build server, or in a git versioned repo, there is no reason to keep a manifest since each deploys a copy of the original is retained from the source control."

I'm not really following what these say. I think they just need a few corrections and perhaps some clarification. For example, does include --no-backup mean that I won't get a new set of build files in my public directory each time I run cachebust, in that the previous builds get overwritten? Is that what is meant by destructive?

Many thanks again for the great tool!

Hey @ianengelbrecht my understanding of the -n flag is that build files are generated but there's no way to rollback the changes cachebust made via the restore option.

Here's an example.

First here's our starter project tree:

index.html
styles.css

The index.html file looks like this:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <title>Cachebust test</title>
    <link href="/styles.css" rel="stylesheet"></link>
  </head>
  <body>
    Test page for cachebust
  </body>
</html>

Running cachebust like this: npx @sparkbox/cachebust -s styles.css -t index.html

which results in this project tree:

.cachebust-manifest.json
index.html
styles.css
styles-dd73dee8fa9df71f08d9b50cf2275703.css

index.html has an update link to the hashed css file and there is a new .cachebust-manifest.json file. This file allows us to rollback the changes made to the index.html file by running: npx @sparkbox/cachebust -r -s styles.css -t index.html.

When we run with -n like this: npx @sparkbox/cachebust -s styles.css -t index.html -n the index.html file is still modified to serve the hashed css file but there is no .cachebust-manifest.json file generated.