Skip to content

Commit

Permalink
fix: use tinyglobby (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
userquin authored Oct 19, 2024
1 parent 4cc62f5 commit 41bd5f0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 44 deletions.
2 changes: 1 addition & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineBuildConfig({
clean: true,
declaration: true,
externals: [
'fast-glob',
'tinyglobby',
'vite',
'vite-plugin-pwa',
'workbox-build',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@vite-pwa/sveltekit",
"type": "module",
"version": "0.6.5",
"packageManager": "pnpm@9.9.0",
"packageManager": "pnpm@9.12.2",
"description": "Zero-config PWA for SvelteKit",
"author": "antfu <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -61,6 +61,7 @@
}
},
"dependencies": {
"tinyglobby": "^0.2.9",
"kolorist": "^1.8.0"
},
"devDependencies": {
Expand Down
62 changes: 30 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions src/plugins/SvelteKitPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { lstat, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import type { Plugin, ResolvedConfig } from 'vite'
import type { VitePWAOptions, VitePluginPWAAPI } from 'vite-plugin-pwa'

// @ts-expect-error export = is not supported by @types/node
import fg from 'fast-glob'
import { glob } from 'tinyglobby'

export function SvelteKitPlugin(
options: Partial<VitePWAOptions>,
Expand Down Expand Up @@ -89,13 +87,12 @@ export function SvelteKitPlugin(
await rm(path)
}
// move also workbox-*.js when using generateSW
const result = await fg(
['workbox-*.js'], {
cwd: serverOutputDir,
onlyFiles: true,
unique: true,
},
)
const result = await glob({
patterns: ['workbox-*.js'],
cwd: serverOutputDir,
onlyFiles: true,
expandDirectories: false,
})
if (result && result.length > 0) {
path = join(serverOutputDir, result[0]).replace(/\\/g, '/')
await writeFile(
Expand Down

0 comments on commit 41bd5f0

Please sign in to comment.