Skip to content
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

Merged
merged 1 commit into from
May 31, 2017
Merged

Add SW registration template injection #21

merged 1 commit into from
May 31, 2017

Conversation

ragingwind
Copy link
Contributor

Solved #12

@HugoCrd
Copy link

HugoCrd commented May 24, 2017

Hi!

Thanks for this fix :)

There's a small typo here: https://github.com/vuejs-templates/pwa/pull/21/files#diff-6648dbe228d17a7aab49fbc78aee89eaR74
servieWorkerLoader => serviceWorkerLoader

Best,

@ragingwind
Copy link
Contributor Author

@HugoCrd Oh my bad, Thanks a lot. I fixed

Copy link
Collaborator

@addyosmani addyosmani left a 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

@@ -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,
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Collaborator

@jeffposnick jeffposnick left a 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.

@@ -28,7 +28,8 @@ module.exports = merge(baseWebpackConfig, {
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
inject: true,
serviceWorkerLoader: ''
Copy link
Collaborator

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).

Copy link
Contributor Author

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

@ragingwind
Copy link
Contributor Author

@jeffposnick @addyosmani PTAL. I've updated with changing of name in sw files to keep consistence in other build files

@jeffposnick
Copy link
Collaborator

👍

@addyosmani
Copy link
Collaborator

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants