From 5f369876d7ecaffbe47fe5c164e4cf1178980ba8 Mon Sep 17 00:00:00 2001 From: Timothy <1695613+timothyis@users.noreply.github.com> Date: Wed, 19 Dec 2018 00:28:40 +0000 Subject: [PATCH] Use Now 2.0 for building and deployment (#611) --- .nowignore | 8 ++++++++ Dockerfile | 13 ------------- now.json | 23 +++++++++++++++-------- package.json | 8 +++++--- yarn.lock | 14 +++++++++++--- 5 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 .nowignore delete mode 100644 Dockerfile diff --git a/.nowignore b/.nowignore new file mode 100644 index 0000000..5432ecc --- /dev/null +++ b/.nowignore @@ -0,0 +1,8 @@ +.github +LICENSE +README.md +bin +node_modules +cypress +cypress.json +docs diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index bdd25aa..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -# Source: https://github.com/zeit/now-static-build-starter/blob/master/Dockerfile -FROM mhart/alpine-node:10 -# We store all our files in /usr/src to perform the build -WORKDIR /usr/src -# We first add only the files required for installing deps -# If package.json or yarn.lock don't change, no need to re-install later -COPY package.json yarn.lock ./ -# We install our deps -RUN yarn -# We copy all source files -COPY . . -# We run the build and expose as /public -RUN yarn build && yarn export -o /public diff --git a/now.json b/now.json index b481fbf..e6bb377 100644 --- a/now.json +++ b/now.json @@ -1,14 +1,21 @@ { "name": "carbon", - "type": "static", + "version": 2, "public": true, - "static": { - "rewrites": [ - { - "source": "!/?(about)?(embed)", - "destination": "/index.html" - } - ] + "builds": [ + { "src": "package.json", "use": "@now/static-build" } + ], + "routes": [ + { "src": "^/about(.*)", "dest": "/about" }, + { "src": "^/embed(.*)", "dest": "/embed" }, + { "src": "^/_next/(.*)", "dest": "/_next/$1" }, + { "src": "^/static/(.*)", "dest": "/static/$1" }, + { "src": "^/(.*)", "dest": "/index.html" } + ], + "build": { + "env": { + "NODE_ENV": "production" + } }, "github": { "autoAlias": false diff --git a/package.json b/package.json index 271b10c..db3f19f 100644 --- a/package.json +++ b/package.json @@ -15,13 +15,15 @@ "contrib:add": "all-contributors add", "contrib:build": "all-contributors generate", "cy:run": "cypress run", - "cy:open": "cypress open" + "cy:open": "cypress open", + "now-build": "cross-env NODE_ENV=production yarn build && yarn export -o dist" }, "dependencies": { "axios": "^0.18.0", "codemirror": "^5.40.2", "codemirror-graphql": "0.7.1", "codemirror-mode-elixir": "^1.1.1", + "cross-env": "^5.2.0", "dom-to-image": "^2.5.2", "downshift": "^3.1.4", "dropperx": "0.2.1", @@ -34,6 +36,7 @@ "ms": "^2.0.0", "next": "^7.0.2", "next-offline": "^3.0.3", + "prettier": "^1.14.3", "react": "^16.6.0", "react-addons-shallow-compare": "^15.6.2", "react-click-outside": "^3.0.0", @@ -60,8 +63,7 @@ "hex2rgb": "^2.2.0", "husky": "^1.1.2", "lint-staged": "^7.3.0", - "now": "^11.4.6", - "prettier": "^1.14.3" + "now": "^11.4.6" }, "lint-staged": { "*.js": [ diff --git a/yarn.lock b/yarn.lock index 905b848..0877983 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2078,6 +2078,14 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" +cross-env@^5.2.0: + version "5.2.0" + resolved "https://registry.npmjs.org/cross-env/-/cross-env-5.2.0.tgz#6ecd4c015d5773e614039ee529076669b9d126f2" + integrity sha512-jtdNFfFW1hB7sMhr/H6rW1Z45LFqyI431m3qU6bFXcQ3Eh7LtBuG3h74o7ohHZ3crrRkkqHlo4jYHFPcjroANg== + dependencies: + cross-spawn "^6.0.5" + is-windows "^1.0.0" + cross-fetch@2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.2.tgz#a47ff4f7fc712daba8f6a695a11c948440d45723" @@ -3903,7 +3911,7 @@ is-typedarray@~1.0.0: resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= -is-windows@^1.0.2: +is-windows@^1.0.0, is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== @@ -5300,9 +5308,9 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prettier@^1.14.3: +prettier@1.14.3: version "1.14.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.3.tgz#90238dd4c0684b7edce5f83b0fb7328e48bd0895" + resolved "https://registry.npmjs.org/prettier/-/prettier-1.14.3.tgz#90238dd4c0684b7edce5f83b0fb7328e48bd0895" integrity sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg== pretty-bytes@^4.0.2: