Skip to content

Commit 0b0e1c7

Browse files
authored
feat: pass through hot: only to webpack-dev-server (#378)
* feat: pass through `hot: only` to `webpack-dev-server` * chore: changelog * add test
1 parent 90c93ff commit 0b0e1c7

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ _Please add entries here for your pull requests that are not yet released._
1111

1212
### Added
1313
- Experimental support for other JS package managers using `package_json` gem [PR 349](https://github.com/shakacode/shakapacker/pull/349) by [G-Rath](https://github.com/g-rath).
14+
- Support `hmr: only` configuration [PR 378](https://github.com/shakacode/shakapacker/pull/378) by [SimenB](https://github.com/SimenB).
1415

1516
### Fixed
1617
- Recommend `server` option instead of deprecated `https` option when `--https` is provided [PR 380](https://github.com/shakacode/shakapacker/pull/380) by [G-Rath](https://github.com/g-rath)

lib/shakapacker/dev_server_runner.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def execute_cmd
8787
cmd += ["--progress", "--color"] if @pretty
8888

8989
cmd += ["--hot"] if @hot
90+
cmd += ["only"] if @hot == "only"
91+
9092
cmd += @argv
9193

9294
Dir.chdir(@app_path) do

spec/shakapacker/dev_server_runner_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,22 @@
173173
verify_command(cmd)
174174
end
175175

176+
it "supports --hot being 'only'" do
177+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--hot", "only"]
178+
179+
allow(Shakapacker::DevServer).to receive(:new).and_return(
180+
double(
181+
host: "localhost",
182+
port: "3035",
183+
pretty?: false,
184+
protocol: "http",
185+
hmr?: "only"
186+
)
187+
)
188+
189+
verify_command(cmd)
190+
end
191+
176192
it "accepts environment variables" do
177193
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
178194
env = Shakapacker::Compiler.env.dup

0 commit comments

Comments
 (0)