File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ### ` kool run npm run hot ` or ` kool run npm run dev `
2+
3+ > Also valid for ` kool run yarn run hot ` or ` kool run yarn run dev `
4+
5+ ** Problem:**
6+
7+ > Browser cannot request "HMR" (hot module replacement) server successfully in Laravel Mix or Laravel Vite.
8+
9+ > Console errors: ** net::ERR_CONNECTION_REFUSED** or ** net::ERR_EMPTY_RESPONSE** .
10+
11+ ** Answer:**
12+
13+ > Publish the HMR's port to the host and change HMR settings to listen on all IPv4 addresses (` 0.0.0.0 ` ).
14+
15+ For the sake of clarity, let's elect port ` 8080 ` to publish.
16+
17+ In your ` kool.yml ` , apply the following changes:
18+
19+ ``` diff
20+ - npm: kool docker kooldev/node:16 npm
21+ + npm: kool docker -p 8080:8080 kooldev/node:16 npm
22+ ```
23+
24+ - Alternatively, if you don't want to publish the port for your general ` kool run npm ` commands, you may add a new entry.
25+
26+ ** > Laravel Mix**
27+
28+ In your ` webpack.mix.js ` , include the following changes to the ` mix.options ` call.
29+
30+ ``` diff
31+ mix.options({
32+ + hmrOptions: {
33+ + host: '0.0.0.0',
34+ + port: 8080,
35+ + },
36+ });
37+ ```
38+
39+ ** > Laravel Vite**
40+
41+ In your ` vite.config.js ` file, include the following changes to the ` defineConfig ` call.
42+
43+ ``` diff
44+ export default defineConfig({
45+ + server: {
46+ + host: '0.0.0.0',
47+ + port: 8080,
48+ + },
49+ plugins: [
50+ laravel({
51+ input: ['resources/css/app.css', 'resources/js/app.js'],
52+ refresh: true,
53+ }),
54+ ],
55+ });
56+ ```
You can’t perform that action at this time.
0 commit comments