Skip to content
A basic import transformer to optimize react-md imports.
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
scripts
src
.babelrc
.eslintrc.json
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package.json
webpack.config.js

README.md

webpack-react-md-import-transformer

Build Status npm version

A basic import transformer to optimize react-md imports.

Table of contents

Important notice

Since react-md v1.3 the /es imports have been changed from react-md/es/react-md to react-md/es/index. Adjust the transform call in your webpack configuration accordingly.

Installation

  1. install the babel-plugin-transform-imports package:
npm insall --save-dev babel-plugin-transform-imports
  1. install my webpack-react-md-import-transformer package:
npm install --save-dev webpack-react-md-import-transformer
  1. require my package in your webpack.config.js file:
const reactMdTransformer = require('webpack-react-md-import-transformer/lib/webpack-react-md-import-transformer.min');
  1. adjust your js module rule loader to something like that:
{
  test: /\.(js|jsx)$/,
  use: {
    loader: 'babel-loader',
      query: {
        plugins: [
          [require('babel-plugin-transform-imports'), {
            "react-md/es/index": {
              "transform": reactMdTransformer,
              preventFullImport: true
            }
          }]
        ]
      }
    },
  exclude: /node_modules/
}

That's it.

Bugs/Missing components

If you face any build errors feel free to open an issue (https://github.com/Kaishiyoku/webpack-react-md-import-transformer/issues).

Should you face runtime errors where some components are undefined it may be possible that the component import mapping is insufficient for a specific component. In that case please open an issue, too so that I can adjust the mapping rules.

License

MIT (https://github.com/Kaishiyoku/webpack-react-md-import-transformer/blob/master/LICENSE)

Author

Twitter: @kaishiyoku
Website: www.andreas-wiedel.de

/

You can’t perform that action at this time.