Uh oh!
There was an error while loading. Please reload this page.
Import scripts in Service Worker - #2714
Conversation
facebook-github-bot
commented
Jul 3, 2017
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
facebook-github-bot
commented
Jul 3, 2017
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
| } | ||
| const sWPrecacheImportScript = fs.existsSync(resolveApp('public/service-worker-import.js')) | ||
| ? 'service-worker-import.js' |
There was a problem hiding this comment.
We generally use camelCase convention for filenames.
There was a problem hiding this comment.
This is an abbreviation and as such I thought sWPrecacheImportScript should be fine. Are you suggesting sWprecacheImportScript ?
There was a problem hiding this comment.
He's suggesting serviceWorkerImport.js.
There was a problem hiding this comment.
Build script is creating a service-worker.js file - that's why I decided to use service-worker-import.js.
I guess there is such naming convention for files which are served from public directory.
Unlike the testsSetup.js which is located in src dir, this one should be placed in public and is just copied over as it is into build by build script.
There was a problem hiding this comment.
Is this a blocking issue/preventing further review?
piotr-cz
commented
Jul 4, 2017
I'd prefer if the import script would be located in the |
uniquename
commented
Aug 7, 2017
What's the reason that this is not getting implemented? Would be convenient to be able to customize service worker without ejecting. |
chemitaxis
commented
Sep 7, 2017
Hi! Any news about it? Thanks! |
scrombie
commented
Oct 9, 2017
Hi all! Please, any info on this? |
react-scripts-dangerous
commented
Oct 9, 2017
Hello! I'm a bot that helps facilitate testing pull requests. Your pull request (commit c566e73) has been released on npm for testing purposes. npm i react-scripts-dangerous@1.0.11-c566e73.0
# or
yarn add react-scripts-dangerous@1.0.11-c566e73.0
# or
create-react-app --scripts-version=react-scripts-dangerous@1.0.11-c566e73.0 folder/Note that the package has not been reviewed or vetted by the maintainers. Only install it at your own risk! Thanks for your contribution! |
When I run it with react-scripts-dangerous@1.0.11-c566e73.0 and then
|
Hmm, it seems Sorry @uniquename, but this released cut won't work -- I can look into fixing this for future cuts. |
Paduado
commented
Nov 17, 2017
Hi! Is there any chance this would get implemented? Or should I just eject |
tszarzynski
commented
Nov 22, 2017
We had a similar problem while working on a project recently and we didn't want to "eject". Instead, we created a little tool that allows you to append custom service worker code to the one generated by CRA. It's not an ideal solution but worked well for us. Have a look here: https://github.com/bbhlondon/cra-append-sw |
Eder87rh
commented
Nov 26, 2017
Any news?, i dont want to eject |
marcelkornblum
commented
Nov 27, 2017
@Eder87rh try out our tool that @tszarzynski mentioned above (https://github.com/bbhlondon/cra-append-sw) - this PR has been open almost 4 months now and it's an easy way to avoid ejecting if that's your only reason to do it. |
jamland
commented
Nov 27, 2017
Would be cool to have this feature! btw https://github.com/bbhlondon/cra-append-sw rains with errors for me |
uniquename
commented
Nov 27, 2017
It might be possible, that there is not much going on here, because workbox will replace swprecache sooner or later #2340 (comment) |
marcelkornblum
commented
Nov 27, 2017
@jamland could you post an issue please? Sorry it didn't work for you, we built it as we were using it on a project ourselves |
jamland
commented
Nov 28, 2017
@marcelkornblum sure I will! |
DanPen
commented
Dec 8, 2017
Can we get this merged? I'm in dire need :) |
anshul
commented
Dec 27, 2017
Any updates? |
I have no idea why this is still pending. |
Oupsla
commented
Apr 4, 2018
mame-col
commented
Apr 6, 2018
can we custom sw code in cra without ejecting now? |
Timer
commented
Sep 26, 2018
Closing in favor of #4169 which will make the service worker fully configurable. |
This PR adds an ability to use
importScriptsoption ofSWPrecacheWebpackPlugin.How-to:
public/service-worker-import.jsnpm run buildFile is being imported only on service worker install/ update.
Downsides:
Fixes: #2253