Add autoExport (#782)

* Add autoExport

* Upgrade Next.js

* Upgrade Next.js

* export service worker to /public

* fix service worker build - file exported to /public (unwanted)

* next next@canary

* try to fix SW

* try to fix SW

* add back _next routing for now

* try a mix of configs

* Fix service-worker serving

* Remove _next route

* Next 9

* move stuff back into /static

* fix service-worker

* don't use canary next builds

* static/banner.png -> static/brand/banner.png

* remove now-build script
main
Tim Neutkens 6 years ago committed by repo-ranger[bot]
parent 9460af2c4f
commit 7fdda47816

1
.gitignore vendored

@ -8,3 +8,4 @@ cypress/screenshots
.DS_Store
packaged
coverage
public/service-worker.js

@ -51,7 +51,7 @@ export const MetaTags = React.memo(() => (
<meta name="twitter:description" content={description} />
<meta name="og:title" content={title} />
<meta name="og:description" content={description} />
<meta name="og:image" content="/static/banner.png" />
<meta name="og:image" content="/static/brand/banner.png" />
<meta name="theme-color" content="#121212" />
<title>{title}</title>
<link rel="shortcut icon" href="/static/favicon.ico" />

@ -5,9 +5,7 @@ import ms from 'ms'
import { fileToDataURL } from './util'
const client = axios.create({
baseURL: `${
process.env.API_URL || process.env.NODE_ENV === 'production' ? '' : 'http://localhost:4000'
}/api`
baseURL: `${process.env.API_URL || ''}/api`
})
const RATE_LIMIT_CODE = 420

@ -1,3 +1,24 @@
const withOffline = require('next-offline')
module.exports = withOffline({ dontAutoRegisterSw: true })
module.exports = withOffline({
target: 'serverless',
dontAutoRegisterSw: true,
workboxOpts: {
// TODO get default config from `next-offline`?
swDest: 'static/service-worker.js',
globPatterns: ['static/**/*'],
globDirectory: '.',
runtimeCaching: [
{
urlPattern: /^https?.*/,
handler: 'NetworkFirst',
options: {
cacheName: 'offlineCache',
expiration: {
maxEntries: 200
}
}
}
]
}
})

@ -2,26 +2,25 @@
"name": "carbon",
"version": 2,
"public": true,
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
"builds": [{ "src": "package.json", "use": "@now/next" }],
"routes": [
{ "src": "^/about(.*)", "dest": "/about" },
{ "src": "^/embed(.*)", "dest": "/embed" },
{ "src": "^/_next/(.*)", "dest": "/_next/$1" },
{ "src": "^/robots.txt", "dest": "/static/robots.txt" },
{
"src": "^/service-worker.js$",
"dest": "/_next/service-worker.js",
"dest": "/_next/static/service-worker.js",
"headers": {
"Service-Worker-Allowed": "/"
}
},
{
"src": "^/static/(.*)",
"dest": "/static/$1",
"continue": true,
"headers": {
"cache-control": "public, max-age=43200, immutable"
}
},
{ "handle": "filesystem" },
{ "src": "^/(.*)", "dest": "/index.html" }
],
"build": {

@ -16,8 +16,7 @@
"contrib:add": "all-contributors add",
"contrib:build": "all-contributors generate",
"cy:run": "cypress run",
"cy:open": "cypress open",
"now-build": "cross-env NODE_ENV=production yarn build && yarn export -o dist"
"cy:open": "cypress open"
},
"dependencies": {
"@dawnlabs/tacklebox": "^0.0.11",
@ -40,7 +39,7 @@
"match-sorter": "^3.1.1",
"morphmorph": "^0.1.0",
"ms": "^2.1.2",
"next": "9.0.1",
"next": "^9.0.0",
"next-offline": "^4.0.2",
"prettier": "^1.18.2",
"react": "^16.8.6",

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save