Skip to content

Commit

Permalink
chore: remove unused vars, rename plugin function
Browse files Browse the repository at this point in the history
  • Loading branch information
hannoeru committed Apr 28, 2021
1 parent 8dd9f10 commit 30625cf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve } from 'path'
import type { Plugin, ResolvedConfig } from 'vite'
import type { Plugin } from 'vite'
import { Route, ResolvedOptions, UserOptions } from './types'
import { getPageFiles } from './files'
import { generateRoutes, generateClientCode, updateRouteFromHMR } from './generate'
Expand All @@ -8,18 +8,16 @@ import { parseVueRequest } from './query'
import { resolveOptions } from './options'
import { MODULE_IDS, MODULE_ID_VIRTUAL } from './constants'

function routePlugin(userOptions: UserOptions = {}): Plugin {
let config: ResolvedConfig | undefined
function pagesPlugin(userOptions: UserOptions = {}): Plugin {
let generatedRoutes: Route[] | null = null

const options: ResolvedOptions = resolveOptions(userOptions)

return {
name: 'vite-plugin-pages',
enforce: 'pre',
configResolved(_config) {
config = _config
options.root = config.root
configResolved({ root }) {
options.root = root
},
configureServer(server) {
const { ws, watcher } = server
Expand Down Expand Up @@ -107,4 +105,4 @@ function routePlugin(userOptions: UserOptions = {}): Plugin {

export * from './types'
export { generateRoutes }
export default routePlugin
export default pagesPlugin

0 comments on commit 30625cf

Please sign in to comment.