const fs = require ( 'fs' ) ; const path = require ( 'path' ) ; const webpack = require ( 'webpack' ) ; const appDirectory = fs . realpathSync ( process . cwd ( ) ) ; const resolveApp = relativePath => path . resolve ( appDirectory , relativePath ) ; const appIncludes = [ resolveApp ( 'src' ) , resolveApp ( '../shared' ) ] ; module . exports = function override ( config , env ) { config . resolve . plugins = config . resolve . plugins . filter ( plugin => plugin . constructor . name !== 'ModuleScopePlugin' ) ; config . module . rules [ 0 ] . include = appIncludes ; config . module . rules [ 1 ] = null ; config . module . rules [ 2 ] . oneOf [ 1 ] . include = appIncludes ; config . module . rules [ 2 ] . oneOf [ 1 ] . options . plugins = [ require . resolve ( 'babel-plugin-react-native-web' ) , require . resolve ( '@babel/plugin-transform-modules-commonjs' ) , ] . concat ( config . module . rules [ 2 ] . oneOf [ 1 ] . options . plugins ) ; config . module . rules = config . module . rules . filter ( Boolean ) ; config . plugins . push ( new webpack . DefinePlugin ( { __DEV__ : env !== 'production' , } ) ) ; config . resolve . extensions = [ ... config . resolve . extensions , '.ts' , '.tsx' ] ; return config ; } ;