Skip to content

Should I Source Control public/mockServiceWorker.js #1015

Answered by kettanaito
jrock2004 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @jrock2004. That's a great question.

Our stance on whether you should commit the worker script to your VCS has changed over time. In the past, the worker script was generated only by using the npx msw init command. That's why we used to recommend committing the script so that everybody working on your project would be sure they're using the same worker implementation.

Now, I recommend setting up the msw.workerDirectory property in your "package.json":

{
  "msw": {
    "workerDirectory": "./public"
  }
}

With this property set, the worker script will automatically be generated whenever you install msw. This automatization allows you to treat the worker script as an artifact and omit i…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@kettanaito
Comment options

@tmskrtsz
Comment options

@kettanaito
Comment options

@tmskrtsz
Comment options

@alexbjorlig
Comment options

Answer selected by jrock2004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #1014 on December 04, 2021 00:31.