From b308a6891cd5eac17a84ec0b91102e3718ab0eaf Mon Sep 17 00:00:00 2001 From: Kedar Date: Sat, 20 Oct 2018 14:08:52 -0700 Subject: [PATCH] Upgrade to webpack 4 and use react-scripts over custom configs --- .env | 11 +- .env.development | 6 + .travis.yml | 4 +- config/env.js | 69 - config/jest/cssTransform.js | 14 - config/jest/fileTransform.js | 12 - config/paths.js | 77 - config/polyfills.js | 16 - config/webpack.config.dev.js | 265 - config/webpack.config.prod.js | 312 - config/webpackDevServer.config.js | 67 - package.json | 71 +- scripts/build.js | 127 - scripts/start.js | 83 - scripts/test.js | 25 - src/components/Nav/Nav.js | 14 +- src/config.js | 10 +- src/pages/Application/ApplicationDecision.js | 13 +- src/pages/DayOf/Announcements.js | 6 +- src/pages/Exec/CheckinCard.js | 107 +- src/pages/Exec/ExecApplicationDetail.js | 222 +- src/pages/Exec/ExecApplications.js | 145 +- src/pages/Exec/ExecCheckin.js | 180 +- src/pages/Exec/ExecDashboard.js | 270 +- src/pages/Exec/ExecUserDetail.js | 177 +- src/pages/Exec/ExecUsers.js | 126 +- src/pages/Login/index.js | 4 +- src/pages/PasswordReset/index.js | 2 +- src/pages/Register/RegisterForm.js | 1 - src/pages/Register/index.js | 7 +- yarn.lock | 7721 ++++++++++++------ 31 files changed, 6074 insertions(+), 4090 deletions(-) create mode 100644 .env.development delete mode 100644 config/env.js delete mode 100644 config/jest/cssTransform.js delete mode 100644 config/jest/fileTransform.js delete mode 100644 config/paths.js delete mode 100644 config/polyfills.js delete mode 100644 config/webpack.config.dev.js delete mode 100644 config/webpack.config.prod.js delete mode 100644 config/webpackDevServer.config.js delete mode 100644 scripts/build.js delete mode 100644 scripts/start.js delete mode 100644 scripts/test.js diff --git a/.env b/.env index b2be979..0c2eab1 100644 --- a/.env +++ b/.env @@ -1,7 +1,6 @@ #this is the base config, do NOT edit this with your local changes. do that in .env.local, which shouldn't be tracked by git -PUBLIC_URL=https://boilermake.org -BM_REACT_APP_API_BASE_URL=https://api.stage.boilermake.org/v1 -BM_REACT_APP_GOOGLE_ANALYTICS_ID=UA-00000000-1 -BM_REACT_APP_DEBUG_MODE=true -BM_REACT_APP_GITHUB_CLIENT_ID= -BM_REACT_APP_ALLOW_SIGNUPS=false +REACT_APP_API_BASE_URL=https://api.stage.boilermake.org/v1 +REACT_APP_GOOGLE_ANALYTICS_ID=UA-00000000-1 +REACT_APP_DEBUG_MODE=true +REACT_APP_GITHUB_CLIENT_ID= +REACT_APP_ALLOW_SIGNUPS=false diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..0c2eab1 --- /dev/null +++ b/.env.development @@ -0,0 +1,6 @@ +#this is the base config, do NOT edit this with your local changes. do that in .env.local, which shouldn't be tracked by git +REACT_APP_API_BASE_URL=https://api.stage.boilermake.org/v1 +REACT_APP_GOOGLE_ANALYTICS_ID=UA-00000000-1 +REACT_APP_DEBUG_MODE=true +REACT_APP_GITHUB_CLIENT_ID= +REACT_APP_ALLOW_SIGNUPS=false diff --git a/.travis.yml b/.travis.yml index 4cad99d..72d78df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js cache: yarn node_js: -- 6 +- 10 install: - pip install --user awscli - yarn @@ -31,4 +31,4 @@ after_deploy: # Allow `awscli` to make requests to CloudFront. - aws configure set preview.cloudfront true # Invalidate every object in the targeted distribution. - - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" \ No newline at end of file + - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*" diff --git a/config/env.js b/config/env.js deleted file mode 100644 index cc6317d..0000000 --- a/config/env.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const paths = require('./paths'); - -const NODE_ENV = process.env.NODE_ENV; -if (!NODE_ENV) { - throw new Error( - 'The NODE_ENV environment variable is required but was not specified.' - ); -} - -// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use -var dotenvFiles = [ - `${paths.dotenv}.${NODE_ENV}.local`, - `${paths.dotenv}.${NODE_ENV}`, - `${paths.dotenv}.local`, - paths.dotenv, -]; -// Load environment variables from .env* files. Suppress warnings using silent -// if this file is missing. dotenv will never modify any environment variables -// that have already been set. -// https://github.com/motdotla/dotenv -dotenvFiles.forEach(dotenvFile => { - if (fs.existsSync(dotenvFile)) { - require('dotenv').config({ - path: dotenvFile, - }); - } -}); - -// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be -// injected into the application via DefinePlugin in Webpack configuration. -const REACT_APP = /^BM_REACT_APP_/i; - -function getClientEnvironment(publicUrl) { - const raw = Object.keys(process.env) - .filter(key => REACT_APP.test(key)) - .reduce( - (env, key) => { - env[key] = process.env[key]; - return env; - }, - { - // Useful for determining whether we’re running in production mode. - // Most importantly, it switches React into the correct mode. - NODE_ENV: process.env.NODE_ENV || 'development', - // Useful for resolving the correct path to static assets in `public`. - // For example, . - // This should only be used as an escape hatch. Normally you would put - // images into the `src` and `import` them in code to get their paths. - PUBLIC_URL: publicUrl, - } - ); - // Stringify all values so we can feed into Webpack DefinePlugin - const stringified = { - 'process.env': Object.keys(raw).reduce( - (env, key) => { - env[key] = JSON.stringify(raw[key]); - return env; - }, - {} - ), - }; - - return { raw, stringified }; -} - -module.exports = getClientEnvironment; diff --git a/config/jest/cssTransform.js b/config/jest/cssTransform.js deleted file mode 100644 index f1534f6..0000000 --- a/config/jest/cssTransform.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -// This is a custom Jest transformer turning style imports into empty objects. -// http://facebook.github.io/jest/docs/tutorial-webpack.html - -module.exports = { - process() { - return 'module.exports = {};'; - }, - getCacheKey() { - // The output is always the same. - return 'cssTransform'; - }, -}; diff --git a/config/jest/fileTransform.js b/config/jest/fileTransform.js deleted file mode 100644 index ffce0da..0000000 --- a/config/jest/fileTransform.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -const path = require('path'); - -// This is a custom Jest transformer turning file imports into filenames. -// http://facebook.github.io/jest/docs/tutorial-webpack.html - -module.exports = { - process(src, filename) { - return `module.exports = ${JSON.stringify(path.basename(filename))};`; - }, -}; diff --git a/config/paths.js b/config/paths.js deleted file mode 100644 index 0e5a38e..0000000 --- a/config/paths.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -const path = require('path'); -const fs = require('fs'); -const url = require('url'); - -// Make sure any symlinks in the project folder are resolved: -// https://github.com/facebookincubator/create-react-app/issues/637 -const appDirectory = fs.realpathSync(process.cwd()); -const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath); - -// We support resolving modules according to `NODE_PATH`. -// This lets you use absolute paths in imports inside large monorepos: -// https://github.com/facebookincubator/create-react-app/issues/253. - -// It works similar to `NODE_PATH` in Node itself: -// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders - -// We will export `nodePaths` as an array of absolute paths. -// It will then be used by Webpack configs. -// Jest doesn’t need this because it already handles `NODE_PATH` out of the box. - -// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. -// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. -// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 - -const nodePaths = (process.env.NODE_PATH || '') - .split(process.platform === 'win32' ? ';' : ':') - .filter(Boolean) - .filter(folder => !path.isAbsolute(folder)) - .map(resolveApp); - -const envPublicUrl = process.env.PUBLIC_URL; - -function ensureSlash(path, needsSlash) { - const hasSlash = path.endsWith('/'); - if (hasSlash && !needsSlash) { - return path.substr(path, path.length - 1); - } else if (!hasSlash && needsSlash) { - return `${path}/`; - } else { - return path; - } -} - -const getPublicUrl = (appPackageJson) => envPublicUrl || require(appPackageJson).homepage; - -// We use `PUBLIC_URL` environment variable or "homepage" field to infer -// "public path" at which the app is served. -// Webpack needs to know it to put the right