项目作者: Andreyco

项目描述 :
Add jsLingui babel plugins to create-react-app using react-app-rewired
高级语言: JavaScript
项目地址: git://github.com/Andreyco/react-app-rewire-lingui.git
创建时间: 2018-05-02T10:25:31Z
项目社区:https://github.com/Andreyco/react-app-rewire-lingui

开源协议:MIT License

下载


react-app-rewire-lingui

Add jsLingui babel plugins to create-react-app using react-app-rewired

This package adds @lingui/babel-plugin-transform-js and @lingui/babel-plugin-transform-react to you app via react-app-rewired

Installation

npm

  1. npm install --save-dev react-app-rewire-lingui
  2. // these peer dependencies are required, you should add them on your own.
  3. npm install --save-dev @lingui/babel-plugin-transform-js @lingui/babel-plugin-transform-react

Yarn

  1. yarn add --dev react-app-rewire-lingui
  2. // these peer dependencies are required, you should add them on your own.
  3. yarn add --dev @lingui/babel-plugin-transform-js @lingui/babel-plugin-transform-react

Usage

In the config-overrides.js you created for react-app-rewired add this code:

  1. const { rewireLingui } = require('react-app-rewire-lingui');
  2. /* config-overrides.js */
  3. module.exports = function override(config, env) {
  4. return rewireLingui(config, env);
  5. }

If you are using compose utility provided by react-app-rewired to add multiple rewires, use this code:

  1. const { compose } = require('react-app-rewired');
  2. const { createLinguiRewire } = require('react-app-rewire-lingui');
  3. /* config-overrides.js */
  4. module.exports = function override(config, env) {
  5. const rewires = compose(
  6. createRewireForSomeOtherPlugin(),
  7. createRewireEvenFormMorePlugins(),
  8. createLinguiRewire(),
  9. );
  10. return rewires(config, env);
  11. };

Usage with Storybook

When using @storybooks/storybook with CRA via getstorybook, create a webpack.config.js file in .storybook folder and add this code:

  1. const { rewireLingui } = require('react-app-rewire-lingui');
  2. module.exports = function override(config, env) {
  3. return rewireLingui(config, env);
  4. };

License

Licensed under the MIT License, Copyright ©️ 2018 Andrej Badin. See LICENSE.md for more information.