@atomazing-org/mock-plop
Version:
The `@atomazing-org/mock-plop` library is a configuration script designed for Plop, a tool aimed at automating code generation within projects utilizing templates. Specifically, this script focuses on generating and updating files associated with mocks (p
29 lines (24 loc) • 582 B
text/typescript
import { setupWorker } from 'msw/browser'
import { handlers } from './handlers/handlers'
import type { SharedOptions } from 'msw'
export const worker = setupWorker(...handlers)
export const onUnhandledRequest: SharedOptions['onUnhandledRequest'] = (req, print) => {
const excludedExtensions = [
'.woff2',
'.css',
'.tsx',
'.ts',
'.js',
'.png',
'.otf',
'.ttf',
'.woff',
]
const isExcluded = excludedExtensions.some(extension =>
new URL(req?.url).pathname.endsWith(extension),
)
if (isExcluded) {
return
}
print.warning()
}