|
| 1 | +const path = require('path'); |
| 2 | +const webpack = require('webpack'); |
| 3 | + |
| 4 | +module.exports = ({siteDir}, options) => { |
| 5 | + const baseProjectSource = [ |
| 6 | + path.resolve(siteDir, 'src'), |
| 7 | + path.resolve(siteDir, 'node_modules/react-native-web'), |
| 8 | + path.resolve(siteDir, 'node_modules/react-native-ui-lib'), |
| 9 | + // // just for not getting warnings |
| 10 | + path.resolve(siteDir, 'node_modules/react-native-shimmer-placeholder'), |
| 11 | + path.resolve(siteDir, 'node_modules/react-native-linear-gradient') |
| 12 | + // // end just for not getting warnings |
| 13 | + // path.resolve(siteDir, 'node_modules/react-native-haptic-feedback'), |
| 14 | + // path.resolve(siteDir, 'node_modules/react-native-animatable'), |
| 15 | + // path.resolve(siteDir, 'node_modules/react-native-reanimated'), |
| 16 | + // path.resolve(siteDir, 'node_modules/react-native-svg'), |
| 17 | + // path.resolve(siteDir, 'node_modules/react-native-svg-transformer'), |
| 18 | + // path.resolve(siteDir, 'node_modules/@react-native-community/netinfo'), |
| 19 | + // path.resolve(siteDir, 'node_modules/@react-native-community/datetimepicker'), |
| 20 | + // path.resolve(siteDir, 'node_modules/react-native-color'), |
| 21 | + |
| 22 | + // path.resolve(siteDir, 'node_modules/postcss'), |
| 23 | + // path.resolve(siteDir, 'node_modules/postcss-js') |
| 24 | + ]; |
| 25 | + |
| 26 | + const useBabelForRN = { |
| 27 | + loader: 'babel-loader', |
| 28 | + options: { |
| 29 | + cacheDirectory: false, |
| 30 | + // The 'react-native' preset is recommended to match React Native's packager |
| 31 | + presets: ['module:metro-react-native-babel-preset'], |
| 32 | + plugins: ['react-native-web', 'react-native-reanimated/plugin'] |
| 33 | + } |
| 34 | + }; |
| 35 | + |
| 36 | + const babelLoaderAppConfiguration = { |
| 37 | + test: /\.(js|jsx|ts|tsx)$/, |
| 38 | + include: baseProjectSource, |
| 39 | + use: useBabelForRN |
| 40 | + }; |
| 41 | + |
| 42 | + return { |
| 43 | + name: 'uilib-plugin', |
| 44 | + configureWebpack(config, isServer, utils) { |
| 45 | + return { |
| 46 | + mergeStrategy: { |
| 47 | + 'resolve.extensions': 'prepend' |
| 48 | + }, |
| 49 | + plugins: [ |
| 50 | + new webpack.DefinePlugin({ |
| 51 | + process: {env: {}}, |
| 52 | + __DEV__: 'false', |
| 53 | + setImmediate: () => {} |
| 54 | + }) |
| 55 | + ], |
| 56 | + module: { |
| 57 | + rules: [babelLoaderAppConfiguration] |
| 58 | + }, |
| 59 | + resolve: { |
| 60 | + alias: { |
| 61 | + 'react-native$': 'react-native-web' |
| 62 | + }, |
| 63 | + extensions: ['.web.js'] |
| 64 | + } |
| 65 | + }; |
| 66 | + } |
| 67 | + }; |
| 68 | +}; |
0 commit comments