-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Skipping static resource max size is 2.1 MB causes service worker to not cache main.js. #2612
Comments
Ideally I want to remove that warning completely (the text is not very useful). |
To work around false positives like #2433 I'm going to silence the warning for now. If more people feel strongly about this we can add special code to handle this into CRA itself but for now I'd recommend adding a custom postbuild step. "scripts": {
"build": "react-scripts build",
"postbuild": "node check-service-worker.js",
|
I am having the very same issue here (my vendors bundle is just too large). |
I was also burned by suppression of this very important message. My app was 2.2MB, which crossed the limit and thus To fix my app I edited new SWPrecacheWebpackPlugin({
// ...
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
}), I'd say you should restore the message and maybe turn it into a warning instead of error. I admin I didn't quite understand the false positive problem mentioned above, but turning this into a warning won't cause the compilation to fail, right? |
Currently the JavaScript bundle is silently ignored by `create-react-app` on build because its pre-gzip file size is over 2mb. To solve this issue we've ejected from `create-react-app` and have bumped up the maximum file size to cache to 4mb. facebook/create-react-app#2612
Not sure if this should be posted here or SWPrecacheWebpackPlugin, but I figured it should be documented somewhere since it was rough to diagnose.
Description
When the webpack JavaScript bundle becomes to large,
yarn build
throws a warning:Skipping static resource "/home/austin/cra-swcache-broken-repro/build/static/js/main.4f79027e.js" (2.77 MB) - max size is 2.1 MB
as is mentioned in #2433. This seems to cause SWPrecacheWebpackPlugin to skip adding the bundle to the list of assets it will cache, but this is not clear from the error message that this is the case. This breaks any offline functionality an app might have.
Expected behavior
Either a warning about file size and the file is still added to the cache, or a more explicit warning that this error is coming from or causing an error in SWPrecacheWebpackPlugin and that the resource won't be cached.
Actual behavior
As seen in the snippet bellow, there is no main.js in the generated service-worker.js.
"use strict";function setOfCachedUrls(e){return e.keys().then(function(e){return e.map(function(e){return e.url})}).then(function(e){return new Set(e)})}var precacheConfig=[["index.html","8271cbe9809a6bbeca76 83483ce358f0"],["static/css/main.9a0fe4f1.css","3473922d6aed4c20bb69846d6027cacf"],["static/media/logo.5d5d9eef.svg","5d5d9eefa31e5e13a6610d9fa7a283bb"]],cacheName="sw-precache-v3-sw-precache-webpack-plugin-" ...
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
: [email protected]node -v
: v7.10.0npm -v
:4.6.1Then, specify:
Reproducible Demo
Demo
(Thanks for all the work you all have put into CRA, it has made my life a lot simpler!)
The text was updated successfully, but these errors were encountered: