1.0.3 • Published 2 years ago

vite-plugin-dev-url v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vite-plugin-dev-url

A vite plugin to reset vite development server address, including path, search, and hash

中文文档

Install

npm i -D vite-plugin-dev-url

Add plugin to your vite.config.ts:

// vite.config.ts
import vitePluginDevUrl from 'vite-plugin-dev-url'

export default {
  plugins: [
    vitePluginDevUrl({ query: { token: 'abc', userId: 123 }, path: '/test', hash: '#normal' })
  ],
  server: {
    host: "0.0.0.0",
  },
}

Query asynchronous method

// vite.config.ts
import vitePluginDevUrl from 'vite-plugin-dev-url'

export default {
  plugins: [
    vitePluginDevUrl({ query: () => {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve({ psToken: 'abc', psUserId: 123 })
          }, 1e3)
        })
      }, path: '/promise', hash: '#ps'
    })
  ],
  server: {
    host: "0.0.0.0",
  },
}

options

optionsdescriptiontypedefault
openThe application automatically opens in the browser when the developmentserver startsbooleanfalse
queryThe query of the urlobject or function{}
pathThe path of the urlstring''
hashThe hash of the urlstring''
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago