style: format

pull/672/head
Kia King Ishii 3 years ago
parent d447e198d2
commit b853910c32

@ -1,14 +1,14 @@
import { RollupOptions, defineConfig } from 'rollup'
import { promises as fs } from 'fs' import { promises as fs } from 'fs'
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import { RollupOptions, defineConfig } from 'rollup'
import { nodeResolve } from '@rollup/plugin-node-resolve' import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs' import commonjs from '@rollup/plugin-commonjs'
import esbuild from 'rollup-plugin-esbuild' import esbuild from 'rollup-plugin-esbuild'
import json from '@rollup/plugin-json' import json from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace' import replace from '@rollup/plugin-replace'
import dts from 'rollup-plugin-dts'
import alias from '@rollup/plugin-alias' import alias from '@rollup/plugin-alias'
import { resolve } from 'path' import dts from 'rollup-plugin-dts'
import { fileURLToPath } from 'url'
import pkg from './package.json' import pkg from './package.json'
const DEV = !!process.env.DEV const DEV = !!process.env.DEV

@ -5,13 +5,13 @@ import { Alias, AliasOptions } from 'vite'
const require = createRequire(import.meta.url) const require = createRequire(import.meta.url)
const PKG_ROOT = resolve(fileURLToPath(import.meta.url), '../..') const PKG_ROOT = resolve(fileURLToPath(import.meta.url), '../..')
export const DIST_CLIENT_PATH = resolve(PKG_ROOT, 'client') export const DIST_CLIENT_PATH = resolve(PKG_ROOT, 'client')
export const APP_PATH = join(DIST_CLIENT_PATH, 'app') export const APP_PATH = join(DIST_CLIENT_PATH, 'app')
export const SHARED_PATH = join(DIST_CLIENT_PATH, 'shared') export const SHARED_PATH = join(DIST_CLIENT_PATH, 'shared')
export const DEFAULT_THEME_PATH = join(DIST_CLIENT_PATH, 'theme-default') export const DEFAULT_THEME_PATH = join(DIST_CLIENT_PATH, 'theme-default')
// special virtual file // special virtual file. we can't directly import '/@siteData' because
// we can't directly import '/@siteData' because
// - it's not an actual file so we can't use tsconfig paths to redirect it // - it's not an actual file so we can't use tsconfig paths to redirect it
// - TS doesn't allow shimming a module that starts with '/' // - TS doesn't allow shimming a module that starts with '/'
export const SITE_DATA_ID = '@siteData' export const SITE_DATA_ID = '@siteData'
@ -49,9 +49,12 @@ export function resolveAliases(root: string, themeDir: string): AliasOptions {
replacement: join(DIST_CLIENT_PATH, '/theme-default/index') replacement: join(DIST_CLIENT_PATH, '/theme-default/index')
}, },
// alias for local linked development // alias for local linked development
{ find: /^vitepress\//, replacement: PKG_ROOT + '/' }, {
// make sure it always use the same vue dependency that comes with find: /^vitepress\//,
// vitepress itself replacement: PKG_ROOT + '/'
},
// make sure it always use the same vue dependency that comes
// with vitepress itself
{ {
find: /^vue$/, find: /^vue$/,
replacement: vuePath replacement: vuePath

@ -1,11 +1,11 @@
import fs from 'fs-extra' import fs from 'fs-extra'
import { bundle, okMark, failMark } from './bundle' import path from 'path'
import ora from 'ora'
import { BuildOptions } from 'vite' import { BuildOptions } from 'vite'
import { OutputChunk, OutputAsset } from 'rollup'
import { resolveConfig } from '../config' import { resolveConfig } from '../config'
import { renderPage } from './render' import { renderPage } from './render'
import { OutputChunk, OutputAsset } from 'rollup' import { bundle, okMark, failMark } from './bundle'
import ora from 'ora'
import path from 'path'
export async function build( export async function build(
root: string, root: string,

@ -1,6 +1,6 @@
import { build } from 'vite' import { build } from 'vite'
import { SiteConfig } from '..'
import { RollupOutput } from 'rollup' import { RollupOutput } from 'rollup'
import { SiteConfig } from '..'
const virtualEntry = 'client.js' const virtualEntry = 'client.js'

@ -1,11 +1,11 @@
import ora from 'ora' import ora from 'ora'
import path from 'path' import path from 'path'
import fs from 'fs-extra' import fs from 'fs-extra'
import { build, BuildOptions, UserConfig as ViteUserConfig } from 'vite'
import { RollupOutput } from 'rollup'
import { slash } from '../utils/slash' import { slash } from '../utils/slash'
import { APP_PATH } from '../alias'
import { SiteConfig } from '../config' import { SiteConfig } from '../config'
import { RollupOutput } from 'rollup' import { APP_PATH } from '../alias'
import { build, BuildOptions, UserConfig as ViteUserConfig } from 'vite'
import { createVitePressPlugin } from '../plugin' import { createVitePressPlugin } from '../plugin'
import { buildMPAClient } from './buildMPAClient' import { buildMPAClient } from './buildMPAClient'

@ -1,12 +1,12 @@
import path from 'path' import { createRequire } from 'module'
import fs from 'fs-extra' import fs from 'fs-extra'
import { SiteConfig, resolveSiteDataByRoute } from '../config' import path from 'path'
import { HeadConfig, createTitle } from '../shared' import escape from 'escape-html'
import { normalizePath, transformWithEsbuild } from 'vite' import { normalizePath, transformWithEsbuild } from 'vite'
import { RollupOutput, OutputChunk, OutputAsset } from 'rollup' import { RollupOutput, OutputChunk, OutputAsset } from 'rollup'
import { HeadConfig, createTitle } from '../shared'
import { slash } from '../utils/slash' import { slash } from '../utils/slash'
import escape from 'escape-html' import { SiteConfig, resolveSiteDataByRoute } from '../config'
import { createRequire } from 'module'
const require = createRequire(import.meta.url) const require = createRequire(import.meta.url)

@ -1,8 +1,8 @@
export * from './config'
export * from './server' export * from './server'
export * from './markdown/markdown'
export * from './build/build' export * from './build/build'
export * from './serve/serve' export * from './serve/serve'
export * from './config'
export * from './markdown/markdown'
// shared types // shared types
export type { export type {

@ -1,14 +1,14 @@
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
import c from 'picocolors'
import matter from 'gray-matter' import matter from 'gray-matter'
import LRUCache from 'lru-cache' import LRUCache from 'lru-cache'
import { createMarkdownRenderer, MarkdownOptions } from './markdown/markdown'
import { deeplyParseHeader } from './utils/parseHeader'
import { PageData, HeadConfig, EXTERNAL_URL_RE } from './shared' import { PageData, HeadConfig, EXTERNAL_URL_RE } from './shared'
import { slash } from './utils/slash' import { slash } from './utils/slash'
import c from 'picocolors' import { deeplyParseHeader } from './utils/parseHeader'
import _debug from 'debug'
import { getGitTimestamp } from './utils/getGitTimestamp' import { getGitTimestamp } from './utils/getGitTimestamp'
import { createMarkdownRenderer, MarkdownOptions } from './markdown/markdown'
import _debug from 'debug'
const debug = _debug('vitepress:md') const debug = _debug('vitepress:md')
const cache = new LRUCache<string, MarkdownCompileResult>({ max: 1024 }) const cache = new LRUCache<string, MarkdownCompileResult>({ max: 1024 })

@ -1,7 +1,7 @@
import sirv from 'sirv' import sirv from 'sirv'
import compression from 'compression' import compression from 'compression'
import { resolveConfig } from '../config'
import polka from 'polka' import polka from 'polka'
import { resolveConfig } from '../config'
function trimChar(str: string, char: string) { function trimChar(str: string, char: string) {
while (str.charAt(0) === char) { while (str.charAt(0) === char) {
@ -33,8 +33,8 @@ export async function serve(options: ServeOptions = {}) {
immutable: true, immutable: true,
setHeaders(res, pathname) { setHeaders(res, pathname) {
if (!pathname.includes('/assets/')) { if (!pathname.includes('/assets/')) {
// force server validation for non-asset files since they are not // force server validation for non-asset files since they
// fingerprinted. // are not fingerprinted
res.setHeader('cache-control', 'no-cache') res.setHeader('cache-control', 'no-cache')
} }
} }

Loading…
Cancel
Save