diff --git a/packages/native/package.json b/packages/native/package.json index 441b587b..72eee997 100644 --- a/packages/native/package.json +++ b/packages/native/package.json @@ -16,6 +16,7 @@ "license": "Apache-2.0", "main": "dist/node.native.js", "browser": "dist/browser.native.js", + "react-native": "dist/react-native.native.js", "types": "dist/node.native.d.ts", "publishConfig": { "access": "public" diff --git a/packages/native/webpack.config.js b/packages/native/webpack.config.js index 6f5818ca..115073f9 100644 --- a/packages/native/webpack.config.js +++ b/packages/native/webpack.config.js @@ -1,7 +1,9 @@ const nodeConfig = require('./webpack.node'); const browserConfig = require('./webpack.browser'); +const reactNativeConfig = require('./webpack.react-native'); module.exports = [ nodeConfig, browserConfig, + reactNativeConfig, ]; diff --git a/packages/native/webpack.react-native.js b/packages/native/webpack.react-native.js new file mode 100644 index 00000000..26d0a166 --- /dev/null +++ b/packages/native/webpack.react-native.js @@ -0,0 +1,37 @@ +const path = require('path'); +const { DefinePlugin } = require('webpack'); +const { version } = require('./package.json'); + +module.exports = { + mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', + entry: './src/index.js', + output: { + globalObject: 'global', + path: path.resolve(__dirname, 'dist'), + filename: 'react-native.native.js', + library: 'Transifex', + }, + target: 'web', + devtool: 'source-map', + plugins: [ + new DefinePlugin({ + __VERSION__: JSON.stringify(version), + __PLATFORM__: JSON.stringify('react-native'), + }), + ], + module: { + rules: [ + { + test: /\.(js|jsx)$/, + exclude: /(node_modules)/, + use: { + loader: 'babel-loader', + options: { + presets: ['@babel/preset-env'], + plugins: [['@babel/transform-runtime']], + }, + }, + }, + ], + }, +};