Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/simon-he95/unplugin-dns-prefetch


https://github.com/simon-he95/unplugin-dns-prefetch

Last synced: 10 days ago
JSON representation

Awesome Lists containing this project

README

        


unplugin-dns-prefetch


English | 简体中文

自动检测收集打包文件中的外部链接,提升到index.html的head顶部生成dns-prefetch,让dns更早的去做解析

## 🧩 使用

Vite

```ts
// vite.config.ts
import { defineConfig } from 'vite'
import { viteDnsPrefetchPlugin } from 'unplugin-dns-prefetch'
import vue from '@vitejs/plugin-vue'
import type { PluginOption } from 'vite'
export default defineConfig({
plugins: [
vue(),
viteDnsPrefetchPlugin(),
],
})
```


Rollup

```ts
// rollup.config.js
import { rollupDnsPrefetchPlugin } from 'unplugin-dns-prefetch'
export default {
plugins: [
rollupDnsPrefetchPlugin(),
],
}
```


Webpack

```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-dns-prefetch').webpackDnsPrefetchPlugin(),
],
}
```


Vue CLI

```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-dns-prefetch').webpackDnsPrefetchPlugin(),
],
},
}
```


ESBuild

```ts
// esbuild.config.js
import { build } from 'esbuild'
import { esbuildDnsPrefetchPlugin } from 'unplugin-dns-prefetch'

build({
plugins: [esbuildDnsPrefetchPlugin()],
})
```

## License
[MIT](./LICENSE) License © 2022 [Simon He](https://github.com/Simon-He95)

Buy Me A Coffee