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

Example of razzle with PWA? #1544

Open
rwehresmann opened this issue Feb 5, 2021 · 7 comments
Open

Example of razzle with PWA? #1544

rwehresmann opened this issue Feb 5, 2021 · 7 comments

Comments

@rwehresmann
Copy link

Is there a working example of razzle with PWA? I know there is a plugin made with this intention, but I just cannot make it work, not sure if there aren't missing instructions there.

If someone could provide an example, it would be great!

@fivethreeo
Copy link
Collaborator

#1448

@rwehresmann
Copy link
Author

rwehresmann commented Feb 6, 2021

How can I merge this whit my current razzle.config.js below?

module.exports = {
  plugins: ['babel-ts'],
  modify: require('razzle-heroku'),
};

@fivethreeo
Copy link
Collaborator

@fivethreeo
Copy link
Collaborator

fivethreeo commented Feb 6, 2021

const { InjectManifest } = require("workbox-webpack-plugin");

module.exports = {
  options: {
    forceRuntimeEnvVars: ['HOST', 'PORT']
  },
  modifyWebpackConfig({
    env: {
      target, 
      dev, 
    },
    webpackConfig, 
    webpackObject, 
    options: {
      razzleOptions,
      webpackOptions, 
    },
    paths, 
  }) {
    const appConfig = Object.assign({}, webpackConfig);
    if (target === "web") {

      appConfig.plugins.push(
        new InjectManifest({ swDest: "sw.js", swSrc: "services.js" }),
      );
    }

    // Do some stuff...
    return appConfig;
  },
};

If you figure this out, please report on your findings 😀

@fivethreeo
Copy link
Collaborator

Ts is builtin in canary.

@fivethreeo
Copy link
Collaborator

@rwehresmann
Copy link
Author

rwehresmann commented Feb 9, 2021

I couldn't make workbox-webpack-plugin configuration work. There is some issue of invalid MIME type when loading the service worker. However, I gave another try to razzle-plugin-pwa and could make it work now. I think this is the easiest way to go :)

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

2 participants