代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/orillusion 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// vite.config.js
import { defineConfig } from 'vite'
import { readFile, writeFile, readdir, lstat } from 'fs/promises'
import { resolve, parse } from 'path'
export default defineConfig(option => ({
server: {
host: '0.0.0.0',
port: 8000,
// hmr: false // open this line if no auto hot-reload required
},
publicDir: option.command === 'build' ? false : 'public',
resolve: {
alias: {
'@orillusion/core': resolve(__dirname, './src/index.ts'),
'@orillusion': resolve(__dirname, './packages'),
'@samples': resolve(__dirname, './samples')
},
mainFields: ['module:dev', 'module']
},
plugins: option.command === 'build' ? undefined : [{
name: 'autoIndex',
configureServer(server) {
const tsFile = /\/src\/.*.ts$/
async function dir(folder, ts = []) {
let files = await readdir(folder)
for (let f of files) {
let path = resolve(folder, f).replace(/\\/g, '/') // fix windows path
let ls = await lstat(path)
if (ls.isDirectory()) {
await dir(path, ts)
} else if (tsFile.test(path)) {
let name = parse(path).name
if (name !== 'index' && !name.startsWith('_') && !name.endsWith('-back'))
ts.push(path)
}
}
return ts
}
async function autoIndex(file) {
if (file && !tsFile.test(file.replace(/\\/g, '/'))) // fix windows path
return
let ts = await dir('./src')
ts.sort() // make sure same sort on windows and unix
let improts = '', _dir = __dirname.replace(/\\/g, '/') + '/src' // fix windows path
for (let path of ts) {
improts += `export * from "${path.replace(_dir, '.').slice(0, -3)}"\r\n`
}
let content = await readFile(resolve(__dirname, './src/index.ts'), 'utf-8')
if (improts !== content) {
console.log('[autoIndex] index.ts')
writeFile(resolve(__dirname, './src/index.ts'), improts)
}
}
server.httpServer.on('listening', autoIndex)
server.watcher.on('change', autoIndex)
server.watcher.on('unlink', autoIndex)
}
}],
build: {
lib: {
entry: resolve(__dirname, './src/index.ts'),
name: 'Orillusion',
fileName: (format) => `orillusion.${format}.max.js`,
},
minify: false
}
}))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。