Skip to content

how add workbox plugin in to razzle #1448

Answered by fivethreeo
behnam-maqsudi asked this question in Q&A
Discussion options

You must be logged in to vote
const { InjectManifest } = require("workbox-webpack-plugin");

module.exports = {
  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;
  },
};
``

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fivethreeo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1448 on October 15, 2020 21:34.