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`
pull/35/head
Eduardo San Martin Morote 4 years ago committed by GitHub
parent b127eed8de
commit 6f10ed6c63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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}`)) console.log(chalk.cyan(`vite v${require('vite/package.json').version}`))
const command = argv._[0] const command = argv._[0]
const root = argv._[command ? 1 : 0]
if (root) {
argv.root = root
}
if (!command || command === 'dev') { if (!command || command === 'dev') {
const port = argv.port || 3000 const port = argv.port || 3000
const root = command === 'dev' && argv._[1]
if (root) {
argv.root = root
}
require('../dist/node') require('../dist/node')
.createServer(argv) .createServer(argv)
.then((server) => { .then((server) => {

@ -84,7 +84,7 @@ function resolvePageImports(
// find the page's js chunk and inject script tags for its imports so that // find the page's js chunk and inject script tags for its imports so that
// they are start fetching as early as possible // 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( const pageChunk = result.assets.find(
(chunk) => chunk.type === 'chunk' && chunk.facadeModuleId === srcPath (chunk) => chunk.type === 'chunk' && chunk.facadeModuleId === srcPath
) as OutputChunk ) as OutputChunk

Loading…
Cancel
Save