question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BRUH! NG BUILD DOES NOT GENERATE SERVICE WORKER!

See original GitHub issue

Bug Report

Affected Package

The issue is caused by package @angular/....

Is this a regression?

No, because every other build before 12, ng build was not supposed to use the --prod flag.

Description

OH EMM GEEE GUYS. After reading the new Angular 12 blog post, I was under the assumption that we no longer needed to use the --prod flag. --prod is supposedly gonna be deprecated right. But then yesterday right before my demo, ngsw-worker.js could not be found. Kept getting a 404. I spent a entire day debugging this, and it turns out, just simply using the --prod flag builds the damned service worker.

In short, someone need to put the damned service worker in the ng build plox or revise the directions so that we go back to the --prod flag.

Minimal Reproduction

This one real simple reproduce yo, just ng build with a project that’s ng added @angular/pwa and such, then ng build, you will not see the ngsw-worker stuff. THEN hit ng build --prod, and it will work as it used to.

Exception or Error


Cannot GET /ngsw-worker.js

Your Environment

Angular Version:


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.0.1
Node: 14.16.1
Package Manager: npm 7.12.0
OS: darwin x64

Angular: 12.0.1
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, material, platform-browser, platform-browser-dynamic
... router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1200.1
@angular-devkit/build-angular   12.0.1
@angular-devkit/core            12.0.1
@angular-devkit/schematics      12.0.1
@angular/fire                   6.1.0-rc.2
@schematics/angular             12.0.1
rxjs                            6.6.7
typescript                      4.2.4

Anything else relevant? It’s pretty hard to just start debugging on without your Chrome Devtools stuff. So just be aware of that.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, May 26, 2021

Thanks @eneajaho. We do not automatically migrate projects that upgrade from a previous version to use production by default. Closing as this is working as planned.

0reactions
angular-automatic-lock-bot[bot]commented, Jun 26, 2021

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng build --watch does not generate ngsw pwa workers. #16883
Talked with @clydin today and it seems that ng build --watch currently does not build service workers because ng serve does not build...
Read more >
angular-cli "ng build" doesn't produce a working project?
I'm new to angular, and just ran into the same issue. You can open up and run the Index.html file in the browser...
Read more >
Angular CLI - Quick Guide - Tutorialspoint
To create a new project, we can run the following command in the command line and the project will be created. ng new...
Read more >
Getting started with service workers - Angular
Creates the service worker configuration file called ngsw-config.json , which ... ng build. The CLI project is now set up to use the...
Read more >
Angular Service Worker | Progressive Web Apps Development
A service worker is a script that browser runs in the background, separate from a web page. With the help of the service...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found