goldhand / goldhand/sw-precache-webpack-plugin

How to strip prefix from just *.html files?

Open
#141 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.4k
Forks
101
PR merge metrics
No merged PRs in 30d

Description

## **BEFORE YOU SUBMIT** please read the following:

* [x] **I'm submitting a support request**

**webpack version:**
^3.5.5

**sw-precache-webpack-plugin version**:
^0.11.4

**Please tell us about your environment:**
Windows 10 with Ubuntu Bash

**Current behavior:**
`index.html` is added to sw with `/assets/`-prefix

**Expected/desired behavior:**
`index.html` is added to sw with no prefix

* **Webpack configuration:**

```javascript
new SWPrecacheWebpackPlugin({
cacheId: '',
filename: 'serviceworker.js',
minify: false,
maximumFileSizeToCacheInBytes: 3500000,
filepath: path.join(assetsDir, '/serviceworker.js'),
mergeStaticsConfig: true,
staticFileGlobsIgnorePatterns: [/serviceworker\.js$/i],
// This obviously does not work :/
stripPrefixMulti: {
'/assets/index.html': 'index.html'
},
navigateFallback: '/index.html'
})
```

* **Generated service worker (not minified):**
_Irrelevant files ommitted_
https://gist.github.com/phun-ky/c66786d9a91604baf308dbb7ebd4ed6a

I'm trying to cache the html files, but with the current setup, the html files is cached with the `/assets/`-prefix, resulting in no offline support(?) and no caching of the files. How can I achieve what I want to do?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.