unplugin-dns-prefetch
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

unplugin-dns-prefetch

English | 简体中文

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

🧩 使用

Vite
// 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
// rollup.config.js
import { rollupDnsPrefetchPlugin } from 'unplugin-dns-prefetch'
export default {
  plugins: [
    rollupDnsPrefetchPlugin(),
  ],
}

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

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

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

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

License

MIT License © 2022 Simon He

Buy Me A Coffee

Package Sidebar

Install

npm i unplugin-dns-prefetch

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

369 kB

Total Files

6

Last publish

Collaborators

  • simon_he