From 6f10ed6c63b7486f678fdd7eedc888925feb473c Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Thu, 2 Jul 2020 22:10:11 +0200 Subject: [PATCH] fix: use resolve instead of join (#33) Allows the documentation to exist in a folder e.g. `docs`, and running `vitepress dev docs` as well as `vitepress build docs` --- bin/vitepress.js | 8 ++++---- src/node/build/render.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/vitepress.js b/bin/vitepress.js index 0d88de16..836c46e4 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 e481544c..14d67efd 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