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

serviceworker webpacker generator integration fixes/enhancements #85

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ncs1
Copy link

@ncs1 ncs1 commented Jul 6, 2020

Hi,
See issue #84

  • fixes rubocop.yml
  • fix the install generator to take care/modify accordingly when the project uses webpacker as its asset pipeline.
  • updates README.
  • uses @phstc and @stevenharman PR not merged.

@ncs1 ncs1 marked this pull request as draft July 6, 2020 23:23
@ncs1 ncs1 marked this pull request as ready for review July 14, 2020 01:44
@ncs1
Copy link
Author

ncs1 commented Jul 14, 2020

I would appreciate your comments regarding this.
Currently I'm using my fork to work with the serviceworker under Webpacker env and it works great.
I tried to run the test suite but it seems broken, could you clarify ?
Thanks.

@aseroff
Copy link

aseroff commented Aug 12, 2020

seconded, would love some eyes on this

@rossta
Copy link
Owner

rossta commented Dec 17, 2020

@ncs1 Thanks for working on these changes. The main branch is now passing on CircleCI. Would you like to rebase and fix the failing tests on your branch?

@ncs1
Copy link
Author

ncs1 commented Dec 17, 2020

@rossta good to see you here.
This pull request is fairly intrusive; however, I'm using it without problems on my rails 6 app since its introduction here.
I'm fairly busy now, but I'll try to make time to rebase it and clean it up in the upcoming days - (feel free to take it/edit it/DIY as you see fit if you have time now).
In case that the rails app has both sprockets & webpacker, it'll generate the webpacker scaffold - should it be configurable on generate ?

@rossta
Copy link
Owner

rossta commented Dec 20, 2020

Perhaps separate tasks would be the most straightforward?

$ rails g serviceworker:install::sprockets 
$ rails g serviceworker:install::webpacker

@ncs1
Copy link
Author

ncs1 commented Dec 31, 2020

Sorry for the delay, I didn't have much time - but I'm working on it.
Just so you know, running bin/setup and bin/rake for test is broken (as documented in the Development section in the readme).
I managed to run the tests successfully through appraisal - but it wasn't evident and it'll need to be fixed or at least being documented in the readme... (I'll try to put it also)

- using parameter --webpacker on generation
- doc auto-generate for webpacker asset pipeline.
- doc manual setup on webpacker asset pipeline.
- updates js examples
- doc development/testing pointers
- currently slow with appraisal due to rebuild on webpack:install
@ncs1 ncs1 force-pushed the serviceworker_webpacker_enh branch from 6f1e5d7 to c23567c Compare January 7, 2021 03:40
@ncs1
Copy link
Author

ncs1 commented Jan 7, 2021

@rossta please review.
Updated readme.
Added dockerfile, that I used for the tests.
Added tests for the webpacker integration, it made the test suite slower due to the "rails webpacker:install" command on dir generation (making it 3 times in Appraisal test...).
(I'll try to optimize the test suite time when I'll have time, I can get rid of the webpacker:install on generation...)

- uses default application.js generated in webpack install instead of doing whole webpack:install
@ncs1
Copy link
Author

ncs1 commented Jan 9, 2021

Now the test suite runs as before

@Paradoxor
Copy link

+1 for this will help a lot of rails 6 users

@Petrucheqa
Copy link

Hello, I'm new to rails and I would like to implement a service worker in my Rails app.

Its a rails 6 app and i'm a stuck because the gem seems to use sprockets instead of wekpacker.

By default my javascripts files are in app/javascript but the command generate files in assets/javascripts and I don't understand the configuration I should change to use files in app/javascript.

Can you tell me if it's possible at the moment ? Or I need to wait the merge of this branch onto master ?

Thanks !

@ncs1
Copy link
Author

ncs1 commented Apr 24, 2021

Hi @Petrucheqa ,
You can use my repository where this branch is integrated to use it with Rails 6 on webpacker.
https://github.com/ncs1/serviceworker-rails
Use the following in your Gemfile:
"""
gem(
'serviceworker-rails',
git: 'https://github.com/ncs1/serviceworker-rails.git',
branch: 'master'
)
"""

And follow my instructions in the README there to integrate with webpacker.
All the best.

@Petrucheqa
Copy link

I'll try as soon as I can, thanks for your answer @ncs1 !

@juan-apa
Copy link

For those that want to use this version in their project, add this as the branch to be use by the gem by doing:

gem 'serviceworker-rails', git: 'https://github.com/ncs1/serviceworker-rails.git', branch: 'serviceworker_webpacker_enh'

this pulls the source code from this pr by @ncs1

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.

None yet

6 participants