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

Write out to dist/assets/ instead of dist/ #23

Closed
JakeDluhy opened this issue Apr 28, 2016 · 2 comments
Closed

Write out to dist/assets/ instead of dist/ #23

JakeDluhy opened this issue Apr 28, 2016 · 2 comments

Comments

@JakeDluhy
Copy link

Is there a way to write service-worker.js and sw-toolbox.js to the assets directory? I didn't see any options to specify and I don't understand the build process very well (I tried going into the source and changing the destDir on the funnels, but I couldn't get anything to work). Even just where I should change a line of code to specify that I want to write to assets so that I could fork. After I got it working I'd be happy to put in some work making it an option.

Thanks!

@jkleinsc
Copy link
Owner

jkleinsc commented Apr 29, 2016

@JakeDluhy I'm curious why you want to change where service-worker.js and sw-toolbox.js get written to?

You can change where service-worker.js gets written to by passing in the destination location using the serviceWorkerFile option. If you use this option, you must also set the includeRegistration option to false and manually include the registration script in your HTML because that registration script needs to know the location of service-worker.js. You can use the registration script here as the basis to create your own: https://github.com/jkleinsc/broccoli-serviceworker/blob/master/lib/registration.js

Unfortunately right now there is no way to configure where sw-toolbox.js gets written, but we could follow the same pattern that serviceWorkerFile uses. You would need to modify https://github.com/jkleinsc/broccoli-serviceworker/blob/master/lib/service-worker.js and change toolboxLocation to use a option like the one used for serviceWorkerFile: https://github.com/jkleinsc/broccoli-serviceworker/blob/master/lib/service-worker.js#L34

Another thing to possibly do would be to change how the registration code gets pulled in so that it could use the serviceWorkerFile option.

@JakeDluhy
Copy link
Author

Definitely a valid question! At my company we are embedding the ember app within an existing rails app. And unfortunately the deploy process is a little janky/buggy, meaning that instead of deploying all of dist to the CDN, we're deploying just dist/assets. We're working on a fix, but in the short term I'd still like to get service workers going...

Thanks for your help! I'll look into making those changes and seeing if it will help. I found out yesterday after I posted this that you can't serve service-worker.js from a different host (which means that I don't think I'll be able to serve it from the CDN off of my webpage). I suppose I might have to write my own service worker file within our Rails app =/

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

No branches or pull requests

2 participants