From 0d9dc7809c5baba5e8b24a0ecd6b304a3121d319 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 15 Feb 2019 19:46:27 -0800 Subject: [PATCH] chore: upgrade to zeit 2 (#998) --- .gitignore | 2 +- .nowignore | 12 ++++++ now.json | 82 ++++++++++++++++++++++++++++++---------- package.json | 3 +- webpack/client.config.js | 8 +++- 5 files changed, 85 insertions(+), 22 deletions(-) create mode 100644 .nowignore diff --git a/.gitignore b/.gitignore index cb1cb0ca..06a287ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_Store -node_modules +/node_modules /__sapper__ /mastodon /mastodon.log diff --git a/.nowignore b/.nowignore new file mode 100644 index 00000000..06a287ee --- /dev/null +++ b/.nowignore @@ -0,0 +1,12 @@ +.DS_Store +/node_modules +/__sapper__ +/mastodon +/mastodon.log +/src/template.html +/static/*.css +/static/robots.txt +/static/inline-script.js.map +/static/emoji-mart-all.json +/src/inline-script/checksum.js +yarn-error.log diff --git a/now.json b/now.json index 001bac61..149d09bf 100644 --- a/now.json +++ b/now.json @@ -1,25 +1,69 @@ { - "version": 1, - "type": "npm", + "version": 2, "env": { "NODE_ENV": "production" }, - "files": [ - "bin", - "inline-script.js", - "original-static", - "scss", - "server.js", - "src", - "src-build", - "static", - "package.json", - "thirdparty", - "webpack", - "webpack.config.js", - "yarn.lock" + "builds": [ + { + "src": "package.json", + "use": "@now/static-build", + "config": { + "distDir": "__sapper__/export" + } + } ], - "engines": { - "node": "^10.0.0" - } + "routes": [ + { + "src": "^/service-worker\\.js$", + "headers": { + "cache-control": "public,max-age=0" + } + }, + { + "src": "^/(report\\.html|stats\\.json)$", + "headers": { + "cache-control": "public,max-age=3600" + }, + "dest": "client/$1" + }, + { + "src": "^/client/.*\\.(js|css|map)$", + "headers": { + "cache-control": "public,max-age=31536000,immutable" + } + }, + { + "src": "^/.*\\.(png|css|json|svg|jpe?g|map|txt)$", + "headers": { + "cache-control": "public,max-age=3600" + } + }, + { + "src": "^/(accounts/[^/]+(/(follows|followers))?|statuses/[^/]+(/(reblogs|favorites))?|(lists|tags)/[^/]+|settings/instances/[^/.]+\\.[^/]+)$", + "headers": { + "cache-control": "public,max-age=3600", + "content-security-policy": "script-src 'self' 'sha256-EkTiuvkFbkHUWPvTnH6v0H2/i/09DGGwDOyFPJKCYnw=' 'sha256-Rv0XCoOhq4H0QyKE7rEhr+e9GI5gsmGcC04fY0HPORc=' 'sha256-28NJWgGMi7z1BsySG4SYZCjth/ys7dkElS3oIl5ZEqM=' 'sha256-nUHIts9QUqQq4nfffteH1WG3ZeWESwmxZn6bWMNWsiM=' 'sha256-MGLg9fH15qQqEcT+iTfwx/cfVp2MgjSrVt08u3NVKa8=' 'sha256-OQjxgqHHnjfZwkCEsAo2MRjd3GuPmg+RvmjrZd35TN4=' 'sha256-sS3nggZVNGyoYqI7U/PSwnwI4CymIdHNgJwW49qztWo=' 'sha256-aASq1hOJ8PP2cfK9QGXaCLdqgtkDXDb5VFXlSyrpX/M=' 'sha256-1ujkGrbsh0Yx/bquh2I9gkG1ZaZetCkjre6vciK2u7U='; worker-src 'self'; style-src 'self' 'unsafe-inline'; frame-src 'none'; object-src 'none'; manifest-src 'self'", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=15552000", + "x-content-type-options": "nosniff", + "x-download-options": "noopen", + "x-frame-options": "SAMEORIGIN", + "x-xss-protection": "1; mode=block" + }, + "dest": "service-worker-index.html" + }, + { + "src": "^/(.*)", + "headers": { + "cache-control": "public,max-age=3600", + "content-security-policy": "script-src 'self' 'sha256-EkTiuvkFbkHUWPvTnH6v0H2/i/09DGGwDOyFPJKCYnw=' 'sha256-Rv0XCoOhq4H0QyKE7rEhr+e9GI5gsmGcC04fY0HPORc=' 'sha256-28NJWgGMi7z1BsySG4SYZCjth/ys7dkElS3oIl5ZEqM=' 'sha256-nUHIts9QUqQq4nfffteH1WG3ZeWESwmxZn6bWMNWsiM=' 'sha256-MGLg9fH15qQqEcT+iTfwx/cfVp2MgjSrVt08u3NVKa8=' 'sha256-OQjxgqHHnjfZwkCEsAo2MRjd3GuPmg+RvmjrZd35TN4=' 'sha256-sS3nggZVNGyoYqI7U/PSwnwI4CymIdHNgJwW49qztWo=' 'sha256-aASq1hOJ8PP2cfK9QGXaCLdqgtkDXDb5VFXlSyrpX/M=' 'sha256-1ujkGrbsh0Yx/bquh2I9gkG1ZaZetCkjre6vciK2u7U='; worker-src 'self'; style-src 'self' 'unsafe-inline'; frame-src 'none'; object-src 'none'; manifest-src 'self'", + "referrer-policy": "no-referrer", + "strict-transport-security": "max-age=15552000", + "x-content-type-options": "nosniff", + "x-download-options": "noopen", + "x-frame-options": "SAMEORIGIN", + "x-xss-protection": "1; mode=block" + } + } + ] } diff --git a/package.json b/package.json index a3cbe8cb..3aad3839 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ "sapper-export": "sapper export", "print-export-info": "node ./bin/print-export-info.js", "export-steps": "run-s before-build sapper-export print-export-info", - "export": "cross-env NODE_ENV=production run-s export-steps" + "export": "cross-env NODE_ENV=production run-s export-steps", + "now-build": "run-s export" }, "dependencies": { "@gamestdio/websocket": "^0.3.1", diff --git a/webpack/client.config.js b/webpack/client.config.js index e4eefedb..df5bfa83 100644 --- a/webpack/client.config.js +++ b/webpack/client.config.js @@ -6,9 +6,15 @@ const terser = require('./terser.config') const CircularDependencyPlugin = require('circular-dependency-plugin') const { mode, dev, resolve } = require('./shared.config') +const output = config.client.output() + +// Zeit does not like filenames with "$" in them, so just keep things simple +output.filename = '[hash]/[id].js' +output.chunkFilename = '[hash]/[id].js' + module.exports = { entry: config.client.entry(), - output: Object.assign(config.client.output(), { globalObject: 'this' }), // enables HMR in workers + output: Object.assign(output, { globalObject: 'this' }), // enables HMR in workers resolve, mode, module: {