Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to strip prefix from just *.html files? #141

Open
1 task done
phun-ky opened this issue Feb 15, 2018 · 2 comments
Open
1 task done

How to strip prefix from just *.html files? #141

phun-ky opened this issue Feb 15, 2018 · 2 comments

Comments

@phun-ky
Copy link

phun-ky commented Feb 15, 2018

BEFORE YOU SUBMIT please read the following:

  • 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:
new SWPrecacheWebpackPlugin({
  cacheId: '<id>',
  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'
})

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?

@phun-ky
Copy link
Author

phun-ky commented Feb 15, 2018

Related to #79 I think

@phun-ky
Copy link
Author

phun-ky commented Feb 15, 2018

With this config:

new SWPrecacheWebpackPlugin({
  cacheId: '<id>',
  filename: '<id>-sw.js',
  minify: false,
  maximumFileSizeToCacheInBytes: 3500000,
  filepath: path.join(assetsDir, '/<id>-sw.js'),
  staticFileGlobs: ['dist/assets/index.html', 'dist/assets/down.html'],
  mergeStaticsConfig: true,
  staticFileGlobsIgnorePatterns: [/<id>-sw\.js$/i],
  stripPrefix: 'dist/assets/',
  navigateFallback: '/index.html'
})

I get:

var precacheConfig = [
  ["/assets/down.html", "0561d4adc94e9ea44ad880dceba708dc"],
  ["/assets/index.html", "400b443ac89eb1a134c9cace50be9edc"],
  ["down.html", "0561d4adc94e9ea44ad880dceba708dc"],
  ["index.html", "400b443ac89eb1a134c9cace50be9edc"]
];

Which is working! How do I get rid of the assets/*.html-entries?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant