-
Notifications
You must be signed in to change notification settings - Fork 506
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
Add SW registration template injection #21
Conversation
Hi! Thanks for this fix :) There's a small typo here: https://github.com/vuejs-templates/pwa/pull/21/files#diff-6648dbe228d17a7aab49fbc78aee89eaR74 Best, |
@HugoCrd Oh my bad, Thanks a lot. I fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we merge this in, would love to get a sanity check on overall approach from @jeffposnick
template/build/webpack.prod.conf.js
Outdated
@@ -14,6 +15,9 @@ var env = {{#if_or unit e2e}}process.env.NODE_ENV === 'testing' | |||
? require('../config/test.env') | |||
: {{/if_or}}config.build.env | |||
|
|||
var serviceWorkerLoader = `<script>${fs.readFileSync(path.join(__dirname, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is only referenced once, shall we just inline it directly in serviceWorkerLoader: <..>
lower down?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@addyosmani done and test in dev mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally fine, with the suggestion about using a no-op SW for the dev environment.
template/build/webpack.dev.conf.js
Outdated
@@ -28,7 +28,8 @@ module.exports = merge(baseWebpackConfig, { | |||
new HtmlWebpackPlugin({ | |||
filename: 'index.html', | |||
template: 'index.html', | |||
inject: true | |||
inject: true, | |||
serviceWorkerLoader: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative to loading nothing would be to load a no-op service worker file, like facebook/create-react-app@8b426ad
That works around an issue where someone might accidentally start up their prod environment on the port that they normally use for dev on localhost, causing the prod service worker to stick around indefinitely (see facebook/create-react-app#2272).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update for this
@jeffposnick @addyosmani PTAL. I've updated with changing of name in sw files to keep consistence in other build files |
👍 |
👍 |
Solved #12