Created
August 3, 2020 15:46
-
-
Save huggler/09bf4e3e671654619c7216b0ef75cccb to your computer and use it in GitHub Desktop.
next.config.js da odete.com.br hospedada na vercel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
/* eslint-disable */ | |
const withPlugins = require('next-compose-plugins'); | |
const withSass = require('@zeit/next-sass'); | |
const withCSS = require('@zeit/next-css'); | |
const withOffline = require('next-offline'); | |
const withImages = require('next-images'); | |
const path = require('path') | |
const sassConfig = { | |
cssModules: false, | |
cssLoaderOptions: { | |
importLoaders: 1, | |
localIdentName: '[local]___[name]___[hash:base64:5]' | |
} | |
}; | |
// Esse cara aqui, por default está colocando meus arquivos em cache offline | |
// Esse cara aqui, se auto-registra sozinho | |
// No serviceWorker que ele mesmo cria | |
const version = "0.0.3"; | |
const nextConfig = { | |
dontAutoRegisterSw: true, | |
//generateInDevMode: true, | |
target: 'serverless', | |
transformManifest: (manifest) => { | |
return ['/'].concat(manifest); | |
}, | |
workboxOpts: { | |
swDest: path.join(__dirname, 'static/service-worker.js'), | |
importScripts: ['firebase-messaging-sw.js'], | |
maximumFileSizeToCacheInBytes: 5000000, | |
runtimeCaching: [ | |
// { | |
// urlPattern: /\.(?:png|jpg|jpeg|svg|webp)$/, | |
// handler: 'CacheFirst', | |
// options: { | |
// cacheName: 'images', | |
// expiration: { | |
// maxEntries: 100 | |
// } | |
// } | |
// }, | |
{ | |
urlPattern: /\.(?:mp4|mov)$/, | |
handler: 'CacheFirst', | |
options: { | |
cacheName: 'videos', | |
expiration: { | |
maxEntries: 10 | |
} | |
} | |
}, | |
{ | |
urlPattern: /^https?.*/, | |
handler: 'NetworkFirst', | |
options: { | |
cacheName: `odete-cache`, | |
expiration: { | |
maxEntries: 100, | |
maxAgeSeconds: 100, | |
}, | |
cacheableResponse: { | |
statuses: [0, 200] | |
}, | |
plugins: [ | |
{cacheDidUpdate: (resp) => { | |
/* todo - posso fazer algo aqui */ | |
/*console.log(resp);*/ | |
}} | |
] | |
} | |
} | |
] | |
} | |
}; | |
module.exports = withPlugins([ | |
withImages, | |
[withOffline, nextConfig], | |
], { | |
webpack: (config, options) => { | |
const oldEntry = config.entry | |
config.entry = () => | |
oldEntry().then(entry => { | |
if(entry['main.js']){ | |
entry['main.js'].push(path.join(__dirname, '/utils/offline')) | |
} | |
return entry | |
}); | |
return config | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment