jhamlet / svg-react-loader

Webpack SVG to React Component Loader
MIT License
559 stars 82 forks source link

webpack 2 compatibility #60

Closed monte-hayward closed 7 years ago

monte-hayward commented 7 years ago

The workaround described in #3 does not work with webpack 2.

In index.js import LogoImage from './avatar.svg'; // produces issue in #3

import LogoImage from '-!babel-loader!svg-react-loader!./avatar.svg'; //produces issue below

Logs:

 8:1   error  Unexpected '!' in '-!babel-loader!svg-react-loader!./avatar.svg'. Do not use import syntax to configure webpack loaders  import/no-webpack-loader-syntax
  8:23  error  Absolute imports should come before relative imports                                                                                import/first

✖ 2 problems (2 errors, 0 warnings)

In webpack.config.js

    {
      test: /\.svg$/,
      use: ['babel-loader','svg-react-loader']
    },