Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vite-node): cli option for vite mode #2893

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/vite-node/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cli
.version(version)
.option('-r, --root <path>', 'Use specified root directory')
.option('-c, --config <path>', 'Use specified config file')
.option('-m, --mode <mode>', 'Set env mode')
.option('-w, --watch', 'Restart on file changes, similar to "nodemon"')
.option('--script', 'Use vite-node as a script runner')
.option('--options <options>', 'Use specified Vite server options')
Expand All @@ -31,6 +32,7 @@ export interface CliOptions {
root?: string
script?: boolean
config?: string
mode?: string
watch?: boolean
options?: ViteNodeServerOptionsCLI
'--'?: string[]
Expand Down Expand Up @@ -60,6 +62,7 @@ async function run(files: string[], options: CliOptions = {}) {
logLevel: 'error',
configFile: options.config,
root: options.root,
mode: options.mode,
plugins: [
options.watch && viteNodeHmrPlugin(),
],
Expand Down Expand Up @@ -115,13 +118,13 @@ function parseServerOptions(serverOptions: ViteNodeServerOptionsCLI): ViteNodeSe
...serverOptions.deps,
inline: inlineOptions !== true
? inlineOptions.map((dep) => {
return dep.startsWith('/') && dep.endsWith('/')
return (dep.startsWith('/') && dep.endsWith('/'))
? new RegExp(dep)
: dep
})
: true,
external: toArray(serverOptions.deps?.external).map((dep) => {
return dep.startsWith('/') && dep.endsWith('/')
return (dep.startsWith('/') && dep.endsWith('/'))
? new RegExp(dep)
: dep
}),
Expand Down