question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack Rebuilds When Swap Files (*.swp, *.swo, *.swn, ...) Change

See original GitHub issue

OS?

Linux (Ubuntu 16.04)

Versions.

@angular/cli: 1.0.0-beta.31 node: 6.9.4 os: linux x64 @angular/common: 4.0.0-beta.7 @angular/compiler: 4.0.0-beta.7 @angular/core: 4.0.0-beta.7 @angular/forms: 4.0.0-beta.7 @angular/http: 4.0.0-beta.7 @angular/platform-browser: 4.0.0-beta.7 @angular/platform-browser-dynamic: 4.0.0-beta.7 @angular/router: 3.4.7 @angular/cli: 1.0.0-beta.31 @angular/compiler-cli: 2.4.7

Repro steps.

  1. Run ng serve
  2. Edit any source file in vim (or similar) but do not save
  3. Webpack recompiles even though you didn’t save.
    1. This is most likely due to vim saving any edit to swap files (*.swp, *.swo, *.swn, …). Webpack registers the change to the swap file and triggers the recompilation.

This seems unnecessary and slows down the workflow. When I actually do want to trigger an update, I save the file. However, now I have to wait for the previous (unnecessary) compilation of the swap files to finish before my actual changed files will be compiled again.

Also, webpack constantly recompiles in the background (due to vim saving to the swap files for every new line) which is a little distracting.

Can you configure webpack to ignore common swap files (*.swp, *.swo, *.swn, …) or allow me—the user—to specify, which files to ignore?

I like @angular/cli. I like webpack. I like vim. Can there be peace?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
joshwienscommented, Feb 13, 2017

@frederikaalund - As a workaround, you could tell vim / neovim to store swap files somewhere else.

Something to the effect of …

#vimrc

set dir=$HOME/.vim_tmp/swap
if !isdirectory(&dir) | call mkdir(&dir, 'p', 0700) | endif

This should send all of the .swp / .swn / .swo to whatever directory you define & create it if it doesn’t exist. Not quite sure how tight you can make the permissions in vim, the above is what I use with neovim so you may need to tinker a bit.

That said, @frederikaalund is correct .swp$ and it’s counterparts should be excluded for us *nix folks 😃

4reactions
jeffjencommented, Mar 1, 2017

Can this be addressed? I was surprised by this behavior when the builder kicks off any time the swap file gets written.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable webpack's file watching for vim swp files
I know nothing about "webpack", but you can tell Vim to store swap files in a single directory instead of the current directory...
Read more >
How to merge a swap (.swp) file to the original file? - Ask Ubuntu
Vim uses .swp files as storage areas for unfinished work, allowing it to edit very large files even if they can't fit completely...
Read more >
Purpose of Swap Files in Vim | Baeldung on Linux
swo or .swn do appear when there are multiple swap files for the same file. vim sets the name for the swap file...
Read more >
What's the easiest way to delete Vim swapfiles I've already ...
A slightly simpler way. From the terminal emulator: $ vim filename. Then inside vim choose recover, and if you want to delete the...
Read more >
Vim .swp and .swo and .swn files
swo file to keep changes. At startup, it will ask if you want to recover the .%.swp file (which is binary). It will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found