We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm run dev
whistle
ctrl + C
const startWhistle = require('whistle') const pkg = require('./package.json') const kill = require('kill-port') ;(async () => { await kill(8899, 'tcp') // 保证运行前8899不被占用 // 配置whistle启动参数 const options = { port: 8899, // 代理端口, rules: { [`\nadmin`]: { rules: [ 'aa bb', 'cc dd', 'gg ee', 'gh ty', 'aa z', ] }, }, } // 启动whistle服务 startWhistle(options, () => { console.log(`whistle started, you can access: http://127.0.0.1:8899/ `) }) })()
我写了个大概,但都不行,源码部分只看到\n是增加分组
\n
The text was updated successfully, but these errors were encountered:
import { dirname, join } from 'path' import whistle from 'whistle' import fs from 'fs/promises' interface IPluginOption { resolveConfig: (option: { port: number }) => Promise<{ port: number uat: string pre: string }> } export default function vitePluginWhistle(options: IPluginOption) { return { name: 'vite-plugin-whistle', async configureServer(server) { server.httpServer.on('listening', async () => { const baseDir = join(process.cwd(), 'whistle') const port = server.httpServer.address().port const pluginConfig = await options.resolveConfig({ port }) const whistleOptions = { name: 'whistle-project', port: pluginConfig.port, rules: { uat: pluginConfig.uat, pre: pluginConfig.pre }, baseDir } const backupFiles = [ '.whistle/rules/properties', '.whistle/rules/files/0.uat', '.whistle/rules/files/1.pre' ] const cache = new Map() for (const element of backupFiles) { try { const content = await fs.readFile(join(baseDir, element), 'utf-8') cache.set(element, content) } catch (error) { // } } await fs.rm(baseDir, { recursive: true, force: true }) for (const [key, value] of cache) { await fs.mkdir(dirname(join(baseDir, key)), { recursive: true }) await fs.writeFile(join(baseDir, key), value) } whistle(whistleOptions) }) } } }
可以参考这个 vite 插件
Sorry, something went wrong.
@DiamondYuan 好的,非常感谢,我先参考研究一下
No branches or pull requests
npm run dev
的时候,同时启动whistle
,同时当ctrl + C
关闭项目的时候,whistle
服务也关闭,或者其他不通过写一个js的方式也行我写了个大概,但都不行,源码部分只看到
\n
是增加分组The text was updated successfully, but these errors were encountered: