blog?

vim, backupcopy and webpack dev server

30 July 2016

This is just a quick note about what seems to be a common gotcha when using vim to develop with webpack's dev server. If you have ever been frustrated by it seemingly ignoring your changes, intermittently reloading, or other similar behavior where it seems like your edits are not being noticed by the dev server, you need to set vim's backupcopy option:

set backupcopy=yes

Doing this in your ~/.vimrc should be sufficient and should also not cause any performance issues on a machine with reasonably fast disks. If your machine isn't that fast or you regularly edit large files, you may want to wrap this option in an autocommand specific to js files:

au BufNewFile,BufReadPre *.js set backupcopy=yes

The backupcopy option controls how new files are written. The three options are making a copy and overwriting the file (backupcopy=yes), renaming the file and writing a new one (backupcopy=no), and automatically selecting a one of the preceding two (backupcopy=auto, the default). More information can be found in the vim documentation: http://vimdoc.sourceforge.net/htmldoc/options.html#'backupcopy'.

Here's the source discussion where I discovered this: https://github.com/webpack/webpack/issues/781

It also seems to be included in the main docs now as well: https://webpack.github.io/docs/webpack-dev-server.html