diff --git a/bin/vitepress.js b/bin/vitepress.js index 0d88de1638d2..836c46e4d569 100755 --- a/bin/vitepress.js +++ b/bin/vitepress.js @@ -6,13 +6,13 @@ console.log(chalk.cyan(`vitepress v${require('../package.json').version}`)) console.log(chalk.cyan(`vite v${require('vite/package.json').version}`)) const command = argv._[0] +const root = argv._[command ? 1 : 0] +if (root) { + argv.root = root +} if (!command || command === 'dev') { const port = argv.port || 3000 - const root = command === 'dev' && argv._[1] - if (root) { - argv.root = root - } require('../dist/node') .createServer(argv) .then((server) => { diff --git a/src/node/build/render.ts b/src/node/build/render.ts index e481544c239e..14d67efd8553 100644 --- a/src/node/build/render.ts +++ b/src/node/build/render.ts @@ -84,7 +84,7 @@ function resolvePageImports( // find the page's js chunk and inject script tags for its imports so that // they are start fetching as early as possible - const srcPath = path.join(config.root, page) + const srcPath = path.resolve(config.root, page) const pageChunk = result.assets.find( (chunk) => chunk.type === 'chunk' && chunk.facadeModuleId === srcPath ) as OutputChunk