-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat: pass through hot: only
to webpack-dev-server
#378
Conversation
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.
Yeah it looks like those tests are pretty busted - this patch looks to be roughly what's needed to fix them:
Index: spec/shakapacker/dev_server_runner_spec.rb
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/spec/shakapacker/dev_server_runner_spec.rb b/spec/shakapacker/dev_server_runner_spec.rb
--- a/spec/shakapacker/dev_server_runner_spec.rb (revision 93d92f521c291c20531e1539e4981e77197f35d2)
+++ b/spec/shakapacker/dev_server_runner_spec.rb (date 1700249852510)
@@ -107,6 +107,38 @@
end.and_return(dev_server)
end
+ it "supports --hot" do
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--hot"]
+
+ dev_server = double()
+ allow(dev_server).to receive(:host).and_return("localhost")
+ allow(dev_server).to receive(:port).and_return("3035")
+ allow(dev_server).to receive(:protocol).and_return("https")
+ allow(dev_server).to receive(:pretty?).and_return(false)
+ allow(dev_server).to receive(:https?).and_return(false)
+ allow(dev_server).to receive(:hmr?).and_return(true)
+
+ allow(Shakapacker::DevServer).to receive(:new).and_return(dev_server)
+
+ verify_command(cmd, argv: [])
+ end
+
+ it "supports --hot being 'only'" do
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--hot", "only"]
+
+ dev_server = double()
+ allow(dev_server).to receive(:host).and_return("localhost")
+ allow(dev_server).to receive(:port).and_return("3035")
+ allow(dev_server).to receive(:protocol).and_return("https")
+ allow(dev_server).to receive(:pretty?).and_return(false)
+ allow(dev_server).to receive(:https?).and_return(false)
+ allow(dev_server).to receive(:hmr?).and_return("only")
+
+ allow(Shakapacker::DevServer).to receive(:new).and_return(dev_server)
+
+ verify_command(cmd, argv: [])
+ end
+
it "accepts environment variables" do
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
env = Shakapacker::Compiler.env.dup
That gets it passing, but it probably means there's some refactoring that could be done to simplify the setup across all the tests.
I think it would be best to fix all the tests in that file in a dedicated PR so this change should be fine to land with or without my patch above
@G-Rath I merged your other chanegs. Please suggest the next steps on this one. |
@SimenB should be able to rebase and add tests now, which should also pretty much be the patch I've written up anyway - also happy to just merge as-is and I can do a new PR adding tests as I know how busy you can get Simen 🙂 |
Hey Gareth! 😀 I'm fine to add tests here - this is for work, so easier to prioritize 🙂 Lemme give it a whack. Especially as it's probably just copying on what you wrote down 👍 |
Pushed up a test. Just tweaking |
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.
LGTM!
@SimenB @ahangarha @G-Rath
|
@justin808 I've already fixed that in #383, the branch is just out of date - so it should be fine to be merged in |
I merged in master, so hopefully this is good to go now |
@SimenB thanks for your contribution! 🌺 |
Summary
Webpack
devServer.hot
property can be set to the stringonly
if you don't want an automatic refresh of the page it the update isn't accepted.https://webpack.js.org/configuration/dev-server/#devserverhot
This PR adds support for that setting in
shakapacker.yml
.I tried adding tests, but changing e.g.
shakapacker/spec/shakapacker/dev_server_runner_spec.rb
Line 58 in c78a5c0
to
verify_command(cmd, argv: (["--nope, not here"]))
does not fail the test - it still passes. So I'm not sure how to test it 😅It does work though - I've verified in my own project.
Pull Request checklist
Update documentation