Update the install generator to add Webpacker configuration#1404
Update the install generator to add Webpacker configuration#1404justin808 merged 41 commits intoshakacode:masterfrom
Conversation
ecef810 to
d1a2080
Compare
d1a2080 to
0cfc67a
Compare
justin808
left a comment
There was a problem hiding this comment.
some comments
Reviewed 15 of 15 files at r1, 1 of 1 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @gscarv13)
.prettierignore, line 11 at r2 (raw file):
spec/react_on_rails/dummy-for-generators/app/javascript/bundles/HelloWorld/* bundle/ lib/generators/react_on_rails/templates/base/base/config/webpack
I don't understand this change
lib/generators/react_on_rails/base_generator.rb, line 67 at r1 (raw file):
base_files = %w[config/webpacker.yml] base_files.each { |file| copy_file("#{base_path}#{file}", file) } end
Please push up a sample public repo with the generator run.
lib/generators/react_on_rails/base_generator.rb, line 95 at r1 (raw file):
puts "Adding dev dependencies" run "yarn add -D @pmmmwh/react-refresh-webpack-plugin fork-ts-checker-webpack-plugin react-refresh"
@Judahmeek we can leave the versions unlocked until the generator fails due to a new version breaking things.
lib/generators/react_on_rails/templates/base/base/babel.config.js, line 2 at r1 (raw file):
// The source code including full typescript support is available at: // https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/babel.config.js
Should we invite people to join the slack to discuss installation/upgrade issues?
lib/generators/react_on_rails/templates/base/base/babel.config.js, line 5 at r1 (raw file):
module.exports = function (api) { const validEnv = ['development', 'test', 'production'];
we could customize the version here: https://github.com/rails/webpacker/blob/master/package/babel/preset.js
we could invoke the function and modify the returned object
lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css, line 2 at r1 (raw file):
.bold { color: green;
name the style
bright
lib/generators/react_on_rails/templates/base/base/config/webpacker.yml, line 62 at r1 (raw file):
# Cache manifest.json for performance cache_manifest: true
this file is installed by rails/webpacker. Not sure we should be overwriting it.
There was a problem hiding this comment.
Reviewable status: 14 of 16 files reviewed, 7 unresolved discussions (waiting on @gscarv13 and @justin808)
.prettierignore, line 11 at r2 (raw file):
Previously, justin808 (Justin Gordon) wrote…
I don't understand this change
Prettier and ESLint rules are conflicting and breaking the CI, I thought it was better to ignore prettier in this case.
lib/generators/react_on_rails/base_generator.rb, line 67 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Please push up a sample public repo with the generator run.
lib/generators/react_on_rails/templates/base/base/config/webpacker.yml, line 62 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
this file is installed by rails/webpacker. Not sure we should be overwriting it.
I added this initially because there are some small changes compared to the one that is installed by default, you can see the diff here https://www.diffchecker.com/ebXd6vc2
Maybe keep the original and mention the changes necessary to make it work on the tutorial?
justin808
left a comment
There was a problem hiding this comment.
Reviewed 2 of 2 files at r4, 11 of 11 files at r5, all commit messages.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @gscarv13 and @justin808)
lib/generators/react_on_rails/base_generator.rb, line 98 at r5 (raw file):
puts "Adding default javascript Rails dependencies" run " yarn add @rails/ujs turbolinks @rails/activestorage"
This makes no sense at all.
Seems totally unnecessary. Did you see https://github.com/shakacode/react_on_rails/blob/master/docs/guides/tutorial.md ?
Why are you adding these?
lib/generators/react_on_rails/base_generator.rb, line 101 at r5 (raw file):
puts "Adding dev dependencies" run "yarn add -D @pmmmwh/react-refresh-webpack-plugin fork-ts-checker-webpack-plugin react-refresh"
base generator should not have TS
it's the basics
lib/generators/react_on_rails/templates/base/base/babel.config.js, line 6 at r5 (raw file):
module.exports = function (api) { // eslint-disable-next-line global-require const defaultConfigFunc = require('@rails/webpacker/package/babel/preset.js');
why is the require inside of the function?
I think there is no reason it can't be outside.
lib/generators/react_on_rails/templates/base/base/Procfile.dev, line 5 at r5 (raw file):
rails: bundle exec rails s -p 3000 wp-client: bin/webpack-dev-server wp-server: SERVER_BUNDLE_ONLY=yes bin/webpack --watch
check the red chars at the line ending
please configure editor correctly
d09941a to
6502884
Compare
6502884 to
6af9ca3
Compare
justin808
left a comment
There was a problem hiding this comment.
Reviewed 6 of 6 files at r6, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @gscarv13)
lib/generators/react_on_rails/base_generator.rb, line 67 at r1 (raw file):
Previously, gscarv13 (Gustavo Carvalho) wrote…
Please add this to the main PR comment.
Can you create a loom video walkthrough of the tutorial.md steps?
lib/generators/react_on_rails/base_generator.rb, line 98 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
This makes no sense at all.
Seems totally unnecessary. Did you see https://github.com/shakacode/react_on_rails/blob/master/docs/guides/tutorial.md ?
Why are you adding these?
OK
@gscarv13 please mark comments as resolved for me next time.
lib/generators/react_on_rails/templates/base/base/babel.config.js, line 2 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Should we invite people to join the slack to discuss installation/upgrade issues?
@gscarv13 can we have the install generator insert a template here?
That way we have ONE copy of the header.
https://dev.to/vinistock/understanding-and-writing-rails-generators-10h1
see the .tt files
https://arsfutura.com/magazine/diy-create-your-own-rails-generator/
template "service.erb", generator_path
that will copy the file and expand templates (erb)
lib/generators/react_on_rails/templates/base/base/config/webpacker.yml, line 62 at r1 (raw file):
Previously, gscarv13 (Gustavo Carvalho) wrote…
Maybe keep the original and mention the changes necessary to make it work on the tutorial?
You're 100% right. We should overwrite it if one is going to use the generator.
lib/generators/react_on_rails/templates/base/base/Procfile.dev-hmr, line 1 at r6 (raw file):
# Procfile for development using HMR
this is not right
you have this reversed and we should update the docs
procfile.dev ==> HMR ==> default
procfile.dev-static ==> static files, not default
gscarv13
left a comment
There was a problem hiding this comment.
Reviewable status: 9 of 24 files reviewed, 6 unresolved discussions (waiting on @gscarv13 and @justin808)
lib/generators/react_on_rails/templates/base/base/Procfile.dev, line 5 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
check the red chars at the line ending
please configure editor correctly
Done.
lib/generators/react_on_rails/templates/base/base/Procfile.dev-hmr, line 1 at r6 (raw file):
Previously, justin808 (Justin Gordon) wrote…
this is not right
you have this reversed and we should update the docs
procfile.dev ==> HMR ==> default
procfile.dev-static ==> static files, not default
Done.
lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css, line 2 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
name the style
bright
Done.
lib/generators/react_on_rails/templates/base/base/config/webpacker.yml, line 62 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
You're 100% right. We should overwrite it if one is going to use the generator.
Done.
lib/generators/react_on_rails/templates/base/base/babel.config.js, line 2 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
@gscarv13 can we have the install generator insert a template here?
That way we have ONE copy of the header.
https://dev.to/vinistock/understanding-and-writing-rails-generators-10h1
see the .tt files
https://arsfutura.com/magazine/diy-create-your-own-rails-generator/
template "service.erb", generator_path
that will copy the file and expand templates (erb)
Done.
gscarv13
left a comment
There was a problem hiding this comment.
Reviewable status: 9 of 24 files reviewed, 6 unresolved discussions (waiting on @justin808)
lib/generators/react_on_rails/base_generator.rb, line 67 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Please add this to the main PR comment.
Can you create a loom video walkthrough of the tutorial.md steps?
Done.
justin808
left a comment
There was a problem hiding this comment.
Reviewed 15 of 15 files at r7, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @gscarv13)
|
@gscarv13 Really fabulous! For the CI failure, need to update the installer so that the new version of @rails/webpcker is used, > 6.0.0.rc.6 - So we need to update that part to the ci. I think maybe we can run something like this after the rails install command, which I think installs the older version of webpacker.
|
ba4a999 to
1a6bf40
Compare
1786326 to
e6e5063
Compare
justin808
left a comment
There was a problem hiding this comment.
Reviewed 4 of 6 files at r16, 2 of 2 files at r17, 4 of 5 files at r18, 1 of 1 files at r19, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @gscarv13)
justin808
left a comment
There was a problem hiding this comment.
I'll merge and release soon.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @gscarv13)


This PR contains:
Updated the generator to add Webpack configuration on
rails generate react_on_rails:installA demo project created with these current changes can be found here
And a quick walkthrough video here
This change is