1 Star 0 Fork 0

biyejun/biye-vitepress

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
rollup.config.ts 2.53 KB
一键复制 编辑 原始数据 按行查看 历史
biyejun 提交于 2023-11-13 18:25 . feat: 启动服务 监听5174端口
import { promises as fs } from 'fs'
import { builtinModules, createRequire } from 'module'
import { resolve } from 'path'
import { fileURLToPath } from 'url'
import { type RollupOptions, defineConfig } from 'rollup'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import esbuild from 'rollup-plugin-esbuild'
import json from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace'
import alias from '@rollup/plugin-alias'
import dts from 'rollup-plugin-dts'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')
const DEV = !!process.env.DEV
const PROD = !DEV
const ROOT = fileURLToPath(import.meta.url)
const r = (p: string) => resolve(ROOT, '..', p)
const external = [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),
...builtinModules.flatMap((m) =>
m.includes('punycode') ? [] : [m, `node:${m}`]
)
]
const plugins = [
alias({
entries: {
'readable-stream': 'stream'
}
}),
replace({
// polyfill broken browser check from bundled deps
'navigator.userAgentData': 'undefined',
'navigator.userAgent': 'undefined',
preventAssignment: true
}),
commonjs(),
nodeResolve({ preferBuiltins: false }),
esbuild({ target: 'node18' }),
json()
]
const esmBuild: RollupOptions = {
input: [r('src/node/index.ts'), r('src/node/cli.ts')],
output: {
format: 'esm',
entryFileNames: `[name].js`,
chunkFileNames: 'serve-[hash].js',
dir: r('dist/node'),
sourcemap: DEV
},
external,
plugins,
onwarn(warning, warn) {
if (warning.code !== 'EVAL') warn(warning)
}
}
const typesExternal = [
...external,
/\/vitepress\/(?!(dist|node_modules)\/).*\.d\.ts$/,
'source-map-js',
'fast-glob'
]
const nodeTypes: RollupOptions = {
input: r('src/node/index.ts'),
output: {
format: 'esm',
file: 'dist/node/index.d.ts'
},
external: typesExternal,
plugins: [dts({ respectExternal: true })]
}
// const clientTypes: RollupOptions = {
// input: r('dist/client-types/index.d.ts'),
// output: {
// format: 'esm',
// file: 'dist/client/index.d.ts'
// },
// external: typesExternal,
// plugins: [
// dts({ respectExternal: true }),
// {
// name: 'cleanup',
// async closeBundle() {
// if (PROD) {
// await fs.rm(r('dist/client-types'), { recursive: true })
// }
// }
// }
// ]
// }
const config = defineConfig([])
config.push(esmBuild)
config.push(nodeTypes)
// config.push(clientTypes)
export default config
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hrbust_cheny/biye-vitepress.git
git@gitee.com:hrbust_cheny/biye-vitepress.git
hrbust_cheny
biye-vitepress
biye-vitepress
study

搜索帮助