antfu / vscode-vite

One step faster for Vite in VS Code ⚡️
https://marketplace.visualstudio.com/items?itemName=antfu.vite
458 stars 24 forks source link

Feature Request: customize start scrpit #3

Open ShenQingchuan opened 3 years ago

ShenQingchuan commented 3 years ago

For now, vscode-vite starts the server while I am opening VSCode, but the script npx vite --port 3000 can't be customized...

ShenQingchuan commented 3 years ago

Feature Describe

It is just for vite and do not influence vitepress or anything else...

I found some code snippets:

if (mode === 'dev') {
    if (ctx.command === 'vitepress') {
      executeCommand(Config.vitepressBase
        ? `npx vitepress dev ${Config.vitepressBase} --port=${ctx.port}`
        : `npx vitepress --port=${ctx.port}`)
    }
    else {
      executeCommand(`npx vite --port=${ctx.port}`)
    }
  }

So I may create a new config item named: "Develop Command and a relative variable named devCommand:

- executeCommand(`npx vite --port=${ctx.port}`)
+ executeCommand(Config.devCommand || `npx vite --port=${ctx.port}`)

I strongly agree that user may need a default start devCommand so I keep the hard-code command there.

Since there is a template string with value interpolation --port=${ctx.port}, the devCommand's default value is supposed to be an empty string;

I found I need to add it in src/config.ts :

+  get devCommand() {
+    return getConfig('devCommand', '')!
+  }

I am lack of VSCode Plugin developing experience ... Here is just some suggestions, maybe not correct 😅😅

antfu commented 3 years ago

Sounds good, let's see the PR, thanks!

vfonic commented 3 years ago

I was looking for the same functionality and then realized that this was already implemented. The only inconvenience was that the --port={ctx.port} was being always appended. I have a script that I call that starts both frontend and backend and passing --port results in an error. I resolved this by starting a single line comment like this: devCommand: foreman start -f Procfile.dev #

wadeKings commented 2 years ago

This extension can run correctly only when the project is opened for the first time. Otherwise, it is blank or inaccessible