{"_id":"react-web-config","_rev":"2-cb25a5b03b6fc3214671fd0298ab887d","name":"react-web-config","description":"react-native-config for web","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"react-web-config","version":"1.0.0","description":"react-native-config for web","main":"lib/index.js","scripts":{"test":"jest","build":"babel src --out-dir lib --ignore **/__tests__/**"},"jest":{"rootDir":"src"},"repository":{"type":"git","url":"git+https://github.com/tanhauhau/react-web-config.git"},"keywords":["react","native","config","react-native-config","react-native-web","web","env","dot-env"],"author":{"name":"Tan Li Hau","email":"lhtan93@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tanhauhau/react-web-config/issues"},"homepage":"https://github.com/tanhauhau/react-web-config#readme","dependencies":{"dotenv":"^4.0.0","webpack":"^2.3.3"},"devDependencies":{"babel-cli":"^6.24.1","babel-core":"^6.24.1","babel-preset-es2015":"^6.24.1","chai":"^3.5.0","karma":"^1.6.0","karma-coverage":"^1.1.1","karma-mocha":"^1.3.0","karma-phantomjs-launcher":"^1.0.4","karma-webpack":"^2.0.3","mocha":"^3.2.0","webpack":"^2.3.3"},"gitHead":"ca7adf00df7fdd6d6ef7d8b206e97b927d5f60ce","_id":"react-web-config@1.0.0","_shasum":"53b8cc12e1c92fe268a49df261c8722b8b510b63","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.4.0","_npmUser":{"name":"tanhauhau","email":"lhtan93@gmail.com"},"dist":{"shasum":"53b8cc12e1c92fe268a49df261c8722b8b510b63","tarball":"https://registry.npmjs.org/react-web-config/-/react-web-config-1.0.0.tgz","integrity":"sha512-WOB3fKtPLhzhu4iGIZgdTX7CBtfrK3arcz+aHNSVHKC34Fw9YhR41ojNTN52xyuFHWVkxK/1SQToNDoMm38pvg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC7Jga75IdbQ6QkmnUozwpJY4gsyR1iLa6IVgHNEhxJOAiAh3wwHrU4Fx/zaoqafDhnoyUK5ayaAJC6rz5BDyGSHLA=="}]},"maintainers":[{"name":"tanhauhau","email":"lhtan93@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/react-web-config-1.0.0.tgz_1492018501607_0.5645618801936507"}}},"readme":"# react-web-config\n\n[![npm version](https://badge.fury.io/js/react-web-config.svg)](https://badge.fury.io/js/react-web-config)\n[![Donate](https://img.shields.io/gratipay/user/tanhauhau.svg)](https://gratipay.com/~tanhauhau/)\n\n[react-native-config](https://github.com/luggit/react-native-config) for Web.\nConfig variables for React Native apps *and React Native Web apps*\n\nModule to expose config variables to your javascript code in React Native, supporting both iOS and Android *and web*.\n\n### Overview\n\n[react-native-web](https://github.com/necolas/react-native-web) is a project to bring [react-native](https://github.com/facebook/react-native) to the web. [Read more](https://github.com/necolas/react-native-web#why).\n\n`react-native-web` lets us to write a single app that runs on mobile platform, ie iOS and Android, as well as browser, however, a typical `react-native` project will use libraries such as `react-native-config` that works perfectly on `react-native` but not on `react-native-web`. `react-web-config` allows you to continue using `react-native-config` seamlessly on the web by adding a few lines in your webpack config.\n\n### Usage\n\nStep 1 and 2 is what you have done if you follow the [guides](https://github.com/luggit/react-native-config#usage) from react-native-config.\n\n\n1) Create a new file `.env` in the root of your React Native app:\n\n```js\n// .env\n\nAPI_URL=https://myapi.com\nGOOGLE_MAPS_API_KEY=abcdefgh\n```\n\n2) Then access variables defined there from your app:\n\n```js\n  // app.js\n  import Config from 'react-native-config'\n  Config.API_URL  // 'https://myapi.com'\n```\n\n\nHowever if you want to have Step 2 to work on a `react-native-web` project, you will need to configure the following in your `webpack.config.js`:\n\n```diff\n  // webpack.config.js\n\n  const webpack = require('webpack');\n+ const ReactWebConfig = require('react-web-config/lib/ReactWebConfig').ReactWebConfig;\n+ const path = require('path');\n\n+ const envFilePath = path.resolve(__dirname, '.env');\n\n  module.exports = {\n    ...\n    plugins: [\n      ...\n+     /* define __REACT_WEB_CONFIG__ */\n+     ReactWebConfig(envFilePath)\n    ],\n    resolve: [\n      alias: [\n        ...\n+       /* set alias from react-native-config to react-web-config */\n+       'react-native-config': 'react-web-config',\n        'react-native': 'react-native-web'\n      ]\n    ]\n  }\n```\n\n### License\n\nMIT\n","maintainers":[{"name":"tanhauhau","email":"lhtan93@gmail.com"}],"time":{"modified":"2022-06-26T08:54:10.108Z","created":"2017-04-12T17:35:02.551Z","1.0.0":"2017-04-12T17:35:02.551Z"},"homepage":"https://github.com/tanhauhau/react-web-config#readme","keywords":["react","native","config","react-native-config","react-native-web","web","env","dot-env"],"repository":{"type":"git","url":"git+https://github.com/tanhauhau/react-web-config.git"},"author":{"name":"Tan Li Hau","email":"lhtan93@gmail.com"},"bugs":{"url":"https://github.com/tanhauhau/react-web-config/issues"},"license":"MIT","readmeFilename":"README.md"}