React-app-rewired: How to add multiple babel plugin

Created on 22 Mar 2018  路  5Comments  路  Source: timarney/react-app-rewired

I want to add babel-plugin-import and babel-plugin-transform-decorators-legacy in the config-overrides.js.

config = injectBabelPlugin(
['transform-decorators-legacy',
'import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }
], config)
config = injectBabelPlugin([
['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }],
'transform-decorators-legacy',
], config)

These two does not work. Could you please add document?

Most helpful comment

    config = injectBabelPlugin('transform-decorators-legacy',config)
    config = injectBabelPlugin(['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }], config)

This works.

All 5 comments

    config = injectBabelPlugin('transform-decorators-legacy',config)
    config = injectBabelPlugin(['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }], config)

This works.

config = injectBabelPlugin(['import', [
        {
            libraryName: "antd-mobile",
            style: true
        },
        {
            libraryName: 'antd',
            style: true
        }
    ]], config);

The "injectBabelPlugin" helper has been deprecated as of v2.0. You can use customize-cra plugins in replacement - https://github.com/arackaf/customize-cra#available-plugins

I have the same error. how can I fix this
The "injectBabelPlugin" helper has been deprecated as of v2.0. You can use customize-cra plugins in replacement - https://github.com/arackaf/customize-cra#available-plugins

my code is

const {injectBabelPlugin} = require('react-app-rewired');
const rewireLess = require('react-app-rewire-less');
module.exports = function override(config, env) {
config = injectBabelPlugin(['import', {libraryName: 'antd', style: true}], config);
config = rewireLess.withLoaderOptions({
modifyVars: {
"@layout-body-background": "#FFFFFF",
"@layout-header-background": "#FFFFFF",
"@layout-footer-background": "#FFFFFF"
},
javascriptEnabled: true
})(config, env);
return config;
};

config = injectBabelPlugin(['import', {libraryName: 'antd-mobile', style: 'css'}, 'antd-mobile'], config)
config = injectBabelPlugin(['import', {libraryName: 'antd', style: 'css'}, 'antd'], config)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bilthon picture bilthon  路  5Comments

lcyuhe picture lcyuhe  路  5Comments

001123 picture 001123  路  4Comments

xiaoxiangmoe picture xiaoxiangmoe  路  3Comments

zhihongzhong picture zhihongzhong  路  4Comments