workbox icon indicating copy to clipboard operation
workbox copied to clipboard

Unable to use workbox-webpack-plugin with angular

Open yelhouti opened this issue 2 years ago • 1 comments

Welcome! Please use this template for reporting bugs or requesting features. For questions about using Workbox, the best place to ask is Stack Overflow, tagged with [workbox]: https://stackoverflow.com/questions/ask?tags=workbox

Library Affected: workbox-webpack-plugin

Browser & Platform: all browsers

Issue or Feature Request Description: I am trying to use workbox-webpack-plugin with angular, but since my code uses typescript, it conflicts with angular ivy compiler.

I created an issue in the angular side, but they won't investigate it: https://github.com/angular/angular/issues/48589 Could anyone here help please.

Reproduction https://github.com/yelhouti/angular-workbox

EDIT: I modified the file form the github repo, by adding this before the merge:

new WorkboxPlugin.InjectManifest({
      swSrc: './src/main/serviceworker/serviceworker.ts',
      swDest: 'serviceworker.js',
      compileSrc: true,
      webpackCompilationPlugins: [
        new AngularWebpackPlugin({
          tsconfig: './tsconfig.serviceworker.json',
        }),
      ]
    })
  );

  config.entry['serviceworker'] = {
    import: './src/main/serviceworker/serviceworker.ts',
    runtime: false
  }

but, not I have two servicworker files: one generated by angular serviceworker.[hash].js and one by this plugin serviceworker.js any idea how I can get rid of the first one ?

yelhouti avatar Dec 26 '22 07:12 yelhouti

This is for an NX workspace though, but the same principles would apply: https://stackoverflow.com/questions/77111579/adding-workbox-to-an-angular-app-in-an-nx-workspace

Hope this helps.

OysteinAmundsen avatar Sep 27 '23 05:09 OysteinAmundsen

Hi there,

Workbox is moving to a new engineering team within Google. As part of this move, we're declaring a partial bug bankruptcy to allow the new team to start fresh. We realize this isn't optimal, but realistically, this is the only way we see it working. For transparency, here're the criteria we applied:

Thanks, and we hope for your understanding! The Workbox team

tomayac avatar Apr 25 '24 08:04 tomayac