Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does "webpack-dev-server"' compile my files to disk?

In webpack's getting started page, under the section about webpack-dev-server it mentions -

The dev server uses webpack’s watch mode. It also prevents webpack from emitting the resulting files to disk. Instead it keeps and serves the resulting files from memory.

Does this mean that the bundled file webpack-dev-server compiles is only kept in memory, and I have to also leave webpack --watch running in the background along with the dev-server process to actually save the compiled file to my hard drive?

like image 204
jchi2241 Avatar asked Dec 03 '16 12:12

jchi2241


People also ask

What does webpack-dev-server do?

webpack-dev-server is Webpack's officially supported CLI-based tool for starting a static server for your assets. While you don't need any CLI tools to use Webpack, webpack-dev-server gives you a single command that starts a static server with built-in live reload.

Where does webpack serve files from?

Using this config webpack-dev-server will serve the static files in your public folder. It'll watch your source files for changes and when changes are made the bundle will be recompiled. This modified bundle is served from memory at the relative path specified in publicPath (see API).

Where are webpack file located?

To answer your specific question, the webpack configuration is stored wherever your global node_modules are installed; on Windows this is typically %AppData%\Roaming\npm\node_modules\powerbi-visuals-tools\lib\webpack.

How does Webpack Dev middleware work?

Webpack Dev Middleware is middleware which can be mounted in an express server to serve the latest compilation of your bundle during development. This uses webpack 's Node API in watch mode and instead of outputting to the file system it outputs to memory.


1 Answers

webpack-dev-server apparently does not compile your code to disk, but rather keeps it in memory. This means you need to either manually compile your changes, or run webpack --watch in the background as you make changes if you want the changes reflected in your compiled file. I learned the hard way.

After digging a little deeper into the webpack-dev-server docs:

This modified bundle is served from memory at the relative path specified in publicPath (see API). It will not be written to your configured output directory. Where a bundle already exists at the same URL path, the bundle in memory takes precedence (by default).

like image 127
jchi2241 Avatar answered Oct 12 '22 03:10

jchi2241