跪拜 Guibai
← Back to the summary

A VS Code Extension That Ships Frontend Builds to Linux in 30 Seconds

Simple Deploy

Simple Deploy is a VS Code extension that uploads locally built frontend or static sites to a Linux server with one click, automatically backing up old code, extracting the new package, and swapping it in to go live, making the release process simpler.


What It Can Do


Prerequisites


First-Time Use

  1. Click the Simple Deploy icon in VS Code's left Activity Bar to open the panel.
  2. Switch to the Servers tab and add your server information.
  3. Switch to the Projects tab and add a deployment project.
  4. Click the project card, confirm the rules, and click Confirm Deployment.
  5. Wait for the deployment to complete, then copy the logs or close the panel.

The extension relies on Suiyi Store for authorization management. Authorization or a trial must be completed before first use.


Interface Description

Panel Entry

Project Card

Displays the project name, target server, and deployment path. Click the card to start deployment.

Server Card

Displays the server name and account information, supporting editing and deletion.


Adding a Server

  1. Open the Simple Deploy panel and switch to the Servers tab.
  2. Click Add Server.
  3. Fill in the form: - Server Name: Give the server a name for easy identification; can be left blank. - Host / IP: The server address. - Port: SSH port, default 22. - Username: SSH login username. - Password: Must be filled in when creating; leave blank when editing to keep the password unchanged.
  4. Click Save.

Passwords are securely stored inside VS Code and will not be displayed in plain text.

Server Preparation

It is recommended to create a dedicated deployment account on the server and grant it permissions for the target directory:

sudo useradd -m deploy
sudo passwd deploy
sudo chown -R deploy:deploy /var/www/app
sudo chmod -R u+rwx /var/www/app

Adding a Project

  1. Switch to the Projects tab and click Add Project.
  2. Fill in the form: - Project Name: Required, e.g., "Official Website Frontend". - Target Server: Required, select from saved servers. - Remote Path: Required, the deployment directory on the server, e.g., /var/www/app. - Pre-command: Optional, a command to execute locally before deployment. - Upload Rules: Required, which files or directories to upload. - Delete Rules: Optional, which files to delete on the server before deployment. - Retention Rules: Optional, which files should not be deleted even if they match a delete rule.
  3. Click Save.

Configuration Details

Remote Path

The directory on the server to deploy to.

Path Allowed
/var/www/app
/var/www
/var ❌ Too short
/ ❌ System root
/var/www/../etc ❌ Contains ..

Upload Rules

Used to specify which local files to upload to the server, using glob syntax:

Symbol Meaning
* Matches any character in the same directory level, excluding /.
** Matches any directory level.
? Matches a single character.
Starts with ! Exclusion, e.g., !node_modules/**.

Common patterns:

Note: dist uploads the entire dist directory; dist/ or dist/** only uploads the contents inside dist.

Upload Root Directory

Each upload rule can specify an upload root directory:

Why is an upload root directory needed?

The upload root directory determines the top-level structure inside the zip package. After the server extracts it, files are placed according to this structure.

Example:

Delete Rules

Purpose:

Before deployment, first delete old files or directories on the server that match the rules to prevent old file remnants from affecting the new version.

Use Cases:

Pattern Examples:

Rule What It Deletes
assets/* Deletes all files directly one level under the assets directory, not subdirectories.
assets/** Deletes all contents under the assets directory, including subdirectories.
index.html Deletes a single file.
**/*.zip Deletes all zip files, regardless of level.

Notes:

Retention Rules

Purpose:

Tell the extension which files or directories should not be deleted even if they match a delete rule.

Use Cases:

Pattern Examples:

Rule What It Retains
uploads/ Retains the entire uploads directory and its contents.
logo.png Retains a single file.
assets/legacy.css Retains legacy.css under the assets directory.
**/*.config.json Retains all files ending with .config.json.

Notes:

Pre-commands

Purpose:

Execute some commands locally before packaging and uploading, typically used to rebuild the project to ensure the latest artifacts are uploaded.

Use Cases:

Field Descriptions:

Field Description
Command The command to execute in the terminal, e.g., bun run build.
Working Dir The directory in which to execute the command. Leave blank for the project root; if filled in, it's a subdirectory of the project root.

Pattern Examples:

Command Working Dir Description
bun run build Blank Execute build at project root, generating dist/.
npm run build Blank Same as above, using npm.
bun run compress dist After build, enter dist directory to compress.
python scripts/copy_assets.py Blank Execute a Python script at the project root.

Notes:

General Rule Restrictions

Upload rules, delete rules, retention rules, and the working directory for pre-commands all follow these restrictions:

These restrictions are in place to prevent misoperation and command injection, ensuring deployment security.


Deployment Process

After clicking Confirm Deployment, the extension performs the following steps in order:

  1. Prepare Deployment: Record basic information such as project, workspace, and rules.
  2. Execute Pre-commands: Execute local commands in order; terminate on failure.
  3. Compress Local Files: Package matched files into a zip, temporarily stored in the system tmp directory.
  4. Connect to Server: Log in to the server via SSH and verify it is a Linux system.
  5. Back Up Old Code: Package the old code on the server and back it up to ~/.static-deploy/.../backups/, keeping a maximum of 20 copies.
  6. Upload Files: Upload the zip via SFTP, displaying progress and speed in real time.
  7. Verify and Extract New Package: Verify the zip integrity on the server and extract it to a temporary directory.
  8. Clear Old Files: Clear the old contents in the target directory, but keep the directory itself.
  9. Replace with New Directory: Replace the temporary directory with the official target directory.
  10. Clean Up Temporary Files: Delete the temporary directory on the server and the local temporary zip.
  11. Deployment Complete: Display success or failure result.

Deployment Panel Introduction

After deployment starts, the deployment panel appears:

If deployment fails, it can automatically restore from backup and clean up temporary files.


Security Tips


FAQ

Deployment fails with "Only Linux servers are supported"

Please confirm that the target server is a Linux system.

Deployment fails with "Password not found for this server"

Edit the corresponding server, re-enter the password, and save.

Pre-command execution failed

First, manually execute the command in the local terminal to confirm it runs correctly, then check if the working directory is correct.

File hierarchy is wrong after upload

Check the upload rules. dist/** uploads the contents inside dist; if you want to keep the dist directory layer, use dist.

Retention rules didn't take effect

Retention rules have higher priority than delete rules, but ensure the rule pattern matches the actual path.

Contact Us

Comments

Top 2 from juejin.cn, machine-translated. The original thread is authoritative.

向新出发叭 1 likes

This VS Code extension is quite thoughtfully made. The deployment flow of 'back up old code → extract to temp directory → full replacement' is designed very solidly, effectively preventing the problem of the live site being left in a 'half-broken' state due to deployment interruption. A few small suggestions for reference: 1. Currently it only supports password login. It would be better if SSH key authentication could be added later, since using password login in a production environment carries higher security risks. 2. If it could automatically trigger a simple health check after deployment (like curling the homepage to check the return code), it would be even more complete. I've used similar tools for frontend project deployment before, and deployment efficiency really improves a lot. But one thing to keep in mind: after deployment, it's best to check if there are any abnormal fluctuations in live performance metrics, like page load time, JS error rate, etc. We had a deployment once where the first screen time suddenly increased by 2 seconds, and later found out it was because the build configuration changed, causing unreasonable chunk splitting. If you use performance monitoring tools (like APM-type ones), keeping an eye on the dashboard data after deployment will give you peace of mind. Just personal experience, for reference~

乘风不带尘

That's so much trouble. I just push to a git server and then set up a server-side CI so it auto-updates on the server after a push.