Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>On Save Run CommandNew to Visual Studio Code? Get it now.
On Save Run Command

On Save Run Command

Jridy

|
98 installs
| (0) | Free
When you set up a .onsaverc file in your workspace, you can define a folder to watch for save events and a javascript file to execute when a file is saved.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

.onsaverc Extension

The .onsaverc extension for Visual Studio Code allows you to define custom actions to be triggered whenever a file is saved within a specific directory.

Installation

To install the extension, follow these steps:

  1. Open Visual Studio Code.
  2. Navigate to the Extensions view by clicking on the square icon in the Sidebar or by pressing Ctrl+Shift+X.
  3. Search for .onsaverc in the Extensions view search box.
  4. Click Install on the .onsaverc extension.

Usage

Once the extension is installed, you can set up .onsaverc files in your project directories to define custom actions.

Creating a .onsaverc File

To define custom actions to perform after save events, create a .onsaverc file in the your visual code studio workspace. The file should be a JSON file with the following structure:

{
    "watch": "<path_to_directory_to_watch>",
    "execute": "<path_to_javascript_file>"
}
  • "watch": The path to the directory you want to watch for saves on.
  • "execute": The path to the JavaScript file to execute when a save occurs.

Example

{
    "watch": "./src",
    "execute": "./scripts/on_save_action.js"
}

Notes

  • Ensure that the specified JavaScript file contains the logic you want to execute when a file is saved.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft