Using webpack-dev-server and HMR
Using webpack-dev-server and HMR¶
While developing, instead of using
encore dev --watch, you can use the
$ ./node_modules/.bin/encore dev-server
This serves the built assets from a new server at
http://localhost:8080 (it does
not actually write any files to disk). This means your
need to change to point to this.
If you’ve activated the manifest.json versioning you’re done: the paths in your templates will automatically point to the dev server.
You can also pass options to the
dev-server command: any options that are supported
by the normal webpack-dev-server. For example:
$ ./node_modules/.bin/encore dev-server --https --port 9000
This will start a server at
Using dev-server inside a VM¶
If you’re using
dev-server from inside a virtual machine, then you’ll need
to bind to all IP addresses and allow any host to access the server:
$ ./node_modules/.bin/encore dev-server --host 0.0.0.0 --disable-host-check
You can now access the dev-server using the IP address to your virtual machine on port 8080 - e.g. http://192.168.1.1:8080.
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.