@@ -12,6 +12,7 @@ const ManifestPlugin = require('webpack-manifest-plugin');
1212const CopyWebpackPlugin = require ( 'copy-webpack-plugin' ) ;
1313const VERSION = require ( '@codesandbox/common/lib/version' ) . default ;
1414// const childProcess = require('child_process');
15+ const RemoveServiceWorkerPlugin = require ( 'webpack-remove-serviceworker-plugin' ) ;
1516const commonConfig = require ( './webpack.common' ) ;
1617
1718const publicPath = '/' ;
@@ -201,143 +202,6 @@ module.exports = merge(commonConfig, {
201202 } ,
202203 ] ,
203204 } ) ,
204- // Generate a service worker script that will precache, and keep up to date,
205- // the HTML & assets that are part of the Webpack build.
206- new SWPrecacheWebpackPlugin ( {
207- // By default, a cache-busting query parameter is appended to requests
208- // used to populate the caches, to ensure the responses are fresh.
209- // If a URL is already hashed by Webpack, then there is no concern
210- // about it being stale, and the cache-busting can be skipped.
211- dontCacheBustUrlsMatching : / \. \w { 8 } \. / ,
212- filename : 'sandbox-service-worker.js' ,
213- cacheId : 'code-sandbox-sandbox' ,
214- logger ( message ) {
215- if ( message . indexOf ( 'Total precache size is' ) === 0 ) {
216- // This message occurs for every build and is a bit too noisy.
217- return ;
218- }
219- if ( message . indexOf ( 'Skipping static resource' ) === 0 ) {
220- // This message obscures real errors so we ignore it.
221- // https://github.com/facebookincubator/create-react-app/issues/2612
222- return ;
223- }
224- // eslint-disable-next-line no-console
225- console . log ( message ) ;
226- } ,
227- minify : true ,
228- // For unknown URLs, fallback to the index page
229- navigateFallback : 'https://new.codesandbox.io/frame.html' ,
230- staticFileGlobs : process . env . SANDBOX_ONLY
231- ? [ 'www/index.html' ]
232- : [ 'www/frame.html' ] ,
233- stripPrefix : 'www/' ,
234- // Ignores URLs starting from /__ (useful for Firebase):
235- // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
236- navigateFallbackWhitelist : [ / ^ (? ! \/ _ _ ) .* / ] ,
237- // Don't precache sourcemaps (they're large) and build asset manifest:
238- staticFileGlobsIgnorePatterns : [ / \. m a p $ / , / a s s e t - m a n i f e s t \. j s o n $ / ] ,
239- maximumFileSizeToCacheInBytes : 1024 * 1024 * 20 , // 20mb
240- runtimeCaching : [
241- {
242- urlPattern : / a p i \/ v 1 \/ s a n d b o x e s / ,
243- handler : 'networkFirst' ,
244- options : {
245- cache : {
246- maxEntries : 50 ,
247- name : 'sandboxes-cache' ,
248- } ,
249- } ,
250- } ,
251- {
252- urlPattern : / a p i \/ v 1 \/ d e p e n d e n c i e s / ,
253- handler : 'fastest' ,
254- options : {
255- cache : {
256- maxAgeSeconds : 60 * 60 * 24 ,
257- name : 'dependency-version-cache' ,
258- } ,
259- } ,
260- } ,
261- {
262- // These should be dynamic, since it's not loaded from this domain
263- // But from the root domain
264- urlPattern : / c o d e s a n d b o x \. i o \/ s t a t i c \/ j s \/ / ,
265- handler : 'fastest' ,
266- options : {
267- cache : {
268- // A day
269- maxAgeSeconds : 60 * 60 * 24 ,
270- name : 'static-root-cache' ,
271- } ,
272- } ,
273- } ,
274- {
275- urlPattern : / \. a m a z o n a w s \. c o m \/ p r o d \/ p a c k a g e / ,
276- handler : 'fastest' ,
277- options : {
278- cache : {
279- // a week
280- maxAgeSeconds : 60 * 60 * 24 * 7 ,
281- name : 'dependency-url-generator-cache' ,
282- } ,
283- } ,
284- } ,
285- {
286- urlPattern : / p r o d - p a c k a g e r - p a c k a g e s \. c s b \. d e v / ,
287- handler : 'fastest' ,
288- options : {
289- cache : {
290- maxAgeSeconds : 60 * 60 * 24 * 7 ,
291- name : 'dependency-files-cache' ,
292- } ,
293- } ,
294- } ,
295- {
296- urlPattern : / ^ h t t p s : \/ \/ u n p k g \. c o m / ,
297- handler : 'cacheFirst' ,
298- options : {
299- cache : {
300- maxEntries : 300 ,
301- name : 'unpkg-dep-cache' ,
302- maxAgeSeconds : 60 * 60 * 24 * 7 ,
303- } ,
304- } ,
305- } ,
306- {
307- urlPattern : / ^ h t t p s : \/ \/ c d n \. r a w g i t \. c o m / ,
308- handler : 'cacheFirst' ,
309- options : {
310- cache : {
311- maxEntries : 300 ,
312- name : 'rawgit-cache' ,
313- maxAgeSeconds : 60 * 60 * 24 * 7 ,
314- } ,
315- } ,
316- } ,
317- {
318- urlPattern : / j s d e l i v r \. ( c o m | n e t ) / ,
319- handler : 'cacheFirst' ,
320- options : {
321- cache : {
322- maxEntries : 300 ,
323- name : 'jsdelivr-dep-cache' ,
324- maxAgeSeconds : 60 * 60 * 24 * 7 ,
325- } ,
326- } ,
327- } ,
328- {
329- urlPattern : / c l o u d f l a r e \. c o m / ,
330- handler : 'cacheFirst' ,
331- options : {
332- cache : {
333- maxEntries : 50 ,
334- name : 'cloudflare-cache' ,
335- maxAgeSeconds : 60 * 60 * 24 * 7 ,
336- } ,
337- } ,
338- } ,
339- ] ,
340- } ) ,
341205 // Moment.js is an extremely popular library that bundles large locale files
342206 // by default due to how Webpack interprets its code. This is a practical
343207 // solution that requires the user to opt into importing specific locales.
@@ -359,6 +223,7 @@ module.exports = merge(commonConfig, {
359223 quality : '95-100' ,
360224 } ,
361225 } ) ,
226+ new RemoveServiceWorkerPlugin ( { filename : 'sandbox-service-worker.js' } ) ,
362227 // isMaster &&
363228 // new SentryWebpackPlugin({
364229 // include: 'src',
0 commit comments