move config of service worker to msw files
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import 'element-internals-polyfill';
|
import 'element-internals-polyfill';
|
||||||
import { worker } from './mocks/browser';
|
import { startMockServiceWorker } from './mocks/browser';
|
||||||
import { UmbExtensionRegistry, UmbExtensionManifest, UmbExtensionManifestCore } from './core/extension';
|
import { UmbExtensionRegistry, UmbExtensionManifest, UmbExtensionManifestCore } from './core/extension';
|
||||||
|
|
||||||
const extensionRegistry = new UmbExtensionRegistry();
|
const extensionRegistry = new UmbExtensionRegistry();
|
||||||
@@ -153,14 +153,5 @@ const setup = async () => {
|
|||||||
await import('./app');
|
await import('./app');
|
||||||
};
|
};
|
||||||
|
|
||||||
worker.start({
|
startMockServiceWorker();
|
||||||
onUnhandledRequest: (req) => {
|
setup();
|
||||||
if (req.url.pathname.startsWith('/node_modules/')) return;
|
|
||||||
if (req.url.pathname.startsWith('/src/')) return;
|
|
||||||
if (req.destination === 'image') return;
|
|
||||||
|
|
||||||
console.warn('Found an unhandled %s request to %s', req.method, req.url.href);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
setup();
|
|
||||||
@@ -1,4 +1,14 @@
|
|||||||
import { setupWorker } from 'msw';
|
import { setupWorker } from 'msw';
|
||||||
import { handlers } from './handlers';
|
import { handlers } from './handlers';
|
||||||
|
|
||||||
export const worker = setupWorker(...handlers);
|
const worker = setupWorker(...handlers);
|
||||||
|
|
||||||
|
export const startMockServiceWorker = () => worker.start({
|
||||||
|
onUnhandledRequest: (req) => {
|
||||||
|
if (req.url.pathname.startsWith('/node_modules/')) return;
|
||||||
|
if (req.url.pathname.startsWith('/src/')) return;
|
||||||
|
if (req.destination === 'image') return;
|
||||||
|
|
||||||
|
console.warn('Found an unhandled %s request to %s', req.method, req.url.href);
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user