Skip to content

Commit

Permalink
feat(vite-node): cli option for vite mode (#2893)
Browse files Browse the repository at this point in the history
  • Loading branch information
abarke authored Feb 22, 2023
1 parent 20c1c84 commit 0fc0803
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit 0fc0803

Please sign in to comment.