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

Write precache-manifest path #1508

Closed
taro-shono opened this issue May 31, 2018 · 5 comments
Closed

Write precache-manifest path #1508

taro-shono opened this issue May 31, 2018 · 5 comments
Labels
Needs More Info Waiting on additional information from the community. workbox-webpack-plugin

Comments

@taro-shono
Copy link

Library Affected:
workbox-webpack-plugin

Browser & Platform:
"all browsers".

Issue or Feature Request Description:
Can write precache-manifest.js dist path

When reporting bugs, please include relevant JavaScript Console logs and links to public URLs at which the issue could be reproduced.

write config:

// config.js
new GenerateSW({
  swDest: path.resolve('./.next/static/sw.js'),
})

generated sw.js: .next/static/sw.js
generated manifest.js: .next/static/precache-manifest.${hash}.js

But this is not corrected path of importScripts

// sw.js
importScripts(
  "static/precache-manifest.fc579fe473694393eb0b73821ed77bae.js" // change `static/` to ``
);

Can I fixed this??

@jeffposnick
Copy link
Contributor

What does the rest of your webpack configuration look like, including the output and publicPath settings?

@jeffposnick jeffposnick added Needs More Info Waiting on additional information from the community. workbox-webpack-plugin labels May 31, 2018
@taro-shono
Copy link
Author

I used nextjs.

My next.config.js:

const {GenerateSW} = require('workbox-webpack-plugin');
const withTypescript = require('@zeit/next-typescript');
const withCSS = require('@zeit/next-css');
const webpack = require('webpack');
const path = require('path');
const Dotenv = require('dotenv-webpack');

module.exports = withTypescript(
  withCSS({
    webpack(config) {
      if (process.env.NODE_ENV === 'develop') {
        config.plugins.push(
          new GenerateSW({
            cacheId: 'mercari-web-jp',
            swDest: path.resolve('./.next/static/sw.js'),
            importsDirectory: 'static',
            // importWorkboxFrom: 'local', TODO: fix this
            clientsClaim: true,
            skipWaiting: true,
            runtimeCaching: [
              {
                urlPattern: '/',
                handler: 'staleWhileRevalidate',
                options: {
                  cacheName: 'top-cache',
                  expiration: {
                    maxEntries: 5,
                    maxAgeSeconds: 60,
                  },
                },
              },
            ],
          })
        )
      }
      return config
    },
  }),
)

versions:

"next": "^6.0.2"
"webpack": "^3.12.0",
"workbox-sw": "^3.2.0",
"workbox-webpack-plugin": "^3.2.0"

@jeffposnick
Copy link
Contributor

Does next expose what the underlying output and publicPath settings are for webpack, under the hood?

@jeffposnick
Copy link
Contributor

In workbox-webpack-plugin v5, we no longer emit a separate precache manifest file, so this is obsolete.

@dhalenok
Copy link

Even though I'm late to the party, but maybe it will help someone:
Here's a workaround I found while looking at next-offline project.

// This option has to be passed to GenerateSW

modifyURLPrefix: {
  'static/': '_next/static/'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info Waiting on additional information from the community. workbox-webpack-plugin
Projects
None yet
Development

No branches or pull requests

3 participants