Created
December 6, 2018 11:10
-
-
Save kitze/9c4976404130bf96dc09c6570be6da8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const fs = require('fs'); | |
const {injectBabelPlugin} = require('react-app-rewired'); | |
const rewireBabelLoader = require('react-app-rewire-babel-loader'); | |
const appDirectory = fs.realpathSync(process.cwd()); | |
const resolveApp = relativePath => path.resolve(appDirectory, relativePath); | |
module.exports = function override(config, env) { | |
let isDev = env === 'development'; | |
delete config.node; | |
config.node = { | |
__dirname: false, | |
__filename: false | |
}; | |
config.target = 'electron-renderer'; | |
config = injectBabelPlugin('transform-do-expressions', config); | |
config = injectBabelPlugin('emotion', config); | |
config = injectBabelPlugin('preval', config); | |
if (!isDev) { | |
// config = injectBabelPlugin('transform-remove-console', config); | |
config = rewireBabelLoader.include( | |
config, | |
resolveApp('node_modules/fix-path'), | |
resolveApp('node_modules/shell-path'), | |
resolveApp('node_modules/shell-env'), | |
resolveApp('node_modules/npm-run-path'), | |
resolveApp('node_modules/path-key'), | |
resolveApp('node_modules/p-finally'), | |
resolveApp('node_modules/default-shell'), | |
resolveApp('node_modules/pify') | |
); | |
} | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment