$ npm install
$ ./node_modules/.bin/webpack-dev-server
$ open http://localhost:8080/webpack-dev-server/
Notes:
- Note the trailing slash on the URL is significant. Without it webpack-dev-server shows a file listing page.
- You need 1.0.11 or later of webpack-dev-middleware for this URL to work. With earlier versions you need to specify the full URL like this:
http://localhost:8080/webpack-dev-server/index.html
. - To get a non-autoreloading version of the page use
http://localhost:8080/index.html
.
I am able to use an
.ejs
template file with WebpackDevServer. The.ejs
template file sits at/src/index.ejs
and the webpack output is sent to/public
.Here are my relevant package versions.
Below is my webpack config file. Reading Facebook's
create-react-app
dev config file for webpack will provide a very clear explanation of all the important config properties. The important thing to keep in mind is that WebpackDevServer serves the build files from memory.The
.ejs
template which sits at/src/index.ejs