Skip to content

Commit

Permalink
fix: can't work with server
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed Aug 31, 2023
1 parent d6ed9b2 commit 0fa7429
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ function cdn(opts: CDNPluginOptions = {}): Plugin[] {
if (logLevel === 'warn') {
scanner.failedModules.forEach((errorMessage, name) => config.logger.error(`vite-plugin-cdn2: ${name} ${errorMessage ? errorMessage : 'resolved failed.Please check it.'}`))
}
// work for serve mode
// https://vitejs.dev/config/dep-optimization-options.html
if (apply === 'serve') {
const exclude = config.optimizeDeps?.exclude || []
config.optimizeDeps.exclude = [...exclude, ...scanner.dependencies.keys()]
}
} catch (error) {
config.logger.error(error)
}
Expand Down

0 comments on commit 0fa7429

Please sign in to comment.