Skip to content

Commit 0434b4b

Browse files
lbogdanCompuIves
authored andcommitted
[WIP] Sandbox service worker changes (#818)
* [WIP] Sandbox service worker changes. * Fixed typo.
1 parent 22beacf commit 0434b4b

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

packages/app/config/webpack.prod.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,32 @@ module.exports = merge(commonConfig, {
128128
},
129129
minify: true,
130130
// For unknown URLs, fallback to the index page
131-
navigateFallback: 'https://new.codesandbox.io/frame.html',
132-
staticFileGlobs: ['www/frame.html'],
133-
stripPrefix: 'www/',
131+
staticFileGlobs: [], // don't pre-cache anything
134132
// Ignores URLs starting from /__ (useful for Firebase):
135133
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
136-
navigateFallbackWhitelist: [/^(?!\/__).*/],
137134
// Don't precache sourcemaps (they're large) and build asset manifest:
138-
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
139135
maximumFileSizeToCacheInBytes: 5242880,
136+
directoryIndex: false,
137+
verbose: true,
140138
runtimeCaching: [
139+
{
140+
urlPattern: /^https:\/\/\w+\.codesandbox\.\w+\/$/, // request to /
141+
handler: 'networkFirst',
142+
options: {
143+
debug: true,
144+
},
145+
},
146+
{
147+
urlPattern: /\.worker\.js$/,
148+
handler: 'cacheFirst',
149+
options: {
150+
cache: {
151+
maxEntries: 50,
152+
name: 'workers-cache',
153+
},
154+
debug: true,
155+
},
156+
},
141157
{
142158
urlPattern: /api\/v1\/sandboxes/,
143159
handler: 'networkFirst',
@@ -146,6 +162,7 @@ module.exports = merge(commonConfig, {
146162
maxEntries: 50,
147163
name: 'sandboxes-cache',
148164
},
165+
debug: true,
149166
},
150167
},
151168
{
@@ -156,19 +173,21 @@ module.exports = merge(commonConfig, {
156173
maxAgeSeconds: 60 * 60 * 24,
157174
name: 'dependency-version-cache',
158175
},
176+
debug: true,
159177
},
160178
},
161179
{
162180
// These should be dynamic, since it's not loaded from this domain
163181
// But from the root domain
164-
urlPattern: /codesandbox\.io\/static\/js\//,
182+
urlPattern: /codesandbox\.\w+\/static\/(js|browserfs)\//,
165183
handler: 'fastest',
166184
options: {
167185
cache: {
168186
// A day
169187
maxAgeSeconds: 60 * 60 * 24,
170188
name: 'static-root-cache',
171189
},
190+
debug: true,
172191
},
173192
},
174193
{
@@ -180,6 +199,7 @@ module.exports = merge(commonConfig, {
180199
maxAgeSeconds: 60 * 60 * 24 * 7,
181200
name: 'dependency-url-generator-cache',
182201
},
202+
debug: true,
183203
},
184204
},
185205
{
@@ -190,6 +210,7 @@ module.exports = merge(commonConfig, {
190210
maxAgeSeconds: 60 * 60 * 24 * 7,
191211
name: 'dependency-files-cache',
192212
},
213+
debug: true,
193214
},
194215
},
195216
{
@@ -201,6 +222,7 @@ module.exports = merge(commonConfig, {
201222
name: 'unpkg-dep-cache',
202223
maxAgeSeconds: 60 * 60 * 24 * 7,
203224
},
225+
debug: true,
204226
},
205227
},
206228
{
@@ -212,6 +234,7 @@ module.exports = merge(commonConfig, {
212234
name: 'jsdelivr-dep-cache',
213235
maxAgeSeconds: 60 * 60 * 24 * 7,
214236
},
237+
debug: true,
215238
},
216239
},
217240
{
@@ -223,6 +246,7 @@ module.exports = merge(commonConfig, {
223246
name: 'cloudflare-cache',
224247
maxAgeSeconds: 60 * 60 * 24 * 7,
225248
},
249+
debug: true,
226250
},
227251
},
228252
],

0 commit comments

Comments
 (0)