Skip to content

Commit

Permalink
fix: sw path again
Browse files Browse the repository at this point in the history
  • Loading branch information
thepassle committed May 15, 2024
1 parent 0e36b89 commit 7d60d72
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/friendly-crabs-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@web/mocks': patch
---

differentiate service worker url between dev and build
3 changes: 2 additions & 1 deletion packages/mocks/browser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './polyfills.js';
import { swPath } from '#sw-path';
import { setupWorker } from 'msw/browser';
import { _registerMockRoutes } from './registerMockRoutes.js';

Expand All @@ -7,7 +8,7 @@ const worker = setupWorker();
const workerPromise = worker
.start({
serviceWorker: {
url: '/__msw_sw__.js',
url: swPath,
},
quiet: true,
// See https://github.com/mswjs/msw/discussions/1231#discussioncomment-2729999 if you'd like to warn if there's a unhandled request
Expand Down
6 changes: 6 additions & 0 deletions packages/mocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
"@web/dev-server": "^0.4.0",
"@web/dev-server-storybook": "^2.0.0"
},
"imports": {
"#sw-path": {
"development": "./sw-path/dev.js",
"default": "./sw-path/build.js"
}
},
"wireit": {
"types": {
"command": "tsc --build --pretty",
Expand Down
1 change: 1 addition & 0 deletions packages/mocks/sw-path/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const swPath = '__msw_sw__.js';
1 change: 1 addition & 0 deletions packages/mocks/sw-path/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const swPath = '/__msw_sw__.js';

0 comments on commit 7d60d72

Please sign in to comment.