daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. set -ex
  3.  
  4. # Overwrites a CRA webpack config with one that loads the config from CRA
  5. # and passes it to a function you control.
  6. overwrite-cra-webpack() {
  7.   echo "const path = require('path')
  8. const extensions = path.join(process.cwd(), 'webpack.config.js')
  9. module.exports = require(extensions)(require('${1}'))"
  10. }
  11.  
  12. (
  13.   # cd to CRA.
  14.   cd node_modules/react-scripts-ts/config
  15.  
  16.   # grab CRA version.
  17.   REACT_SCRIPTS_VERSION=$(node -e "process.stdout.write(require('../package.json').version.toString())")
  18.   # prepare file names.
  19.   FILE_NAME_BASE="webpack.config.${REACT_SCRIPTS_VERSION}"
  20.   DEV_CONFIG="${FILE_NAME_BASE}.dev.orig.js"
  21.   PROD_CONFIG="${FILE_NAME_BASE}.prod.orig.js"
  22.  
  23.   if [ ! -e "${DEV_CONFIG}" ]; then
  24.     # Overwrite dev config.
  25.     cp webpack.config.dev.js "${DEV_CONFIG}"
  26.     overwrite-cra-webpack "./${DEV_CONFIG}" > webpack.config.dev.js
  27.  
  28.     # Overwrite prod config.
  29.     cp webpack.config.prod.js "${PROD_CONFIG}"
  30.     overwrite-cra-webpack "./${PROD_CONFIG}" > webpack.config.prod.js
  31.   fi
  32. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top