jhamlet / svg-react-loader

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

Configuration issues #52

Closed cescoferraro closed 7 years ago

cescoferraro commented 7 years ago

Great LIbrary, congrats!

This works let Image1 = require("-!babel-loader!svg-react-loader!./kiwi.svg"); readme suggests doing { test: /\.svg$/, loader: 'babel-loader?presets[]=es2015,presets[]=react!svg-react-loader' }, but then I get this error Module build failed: Error: Non-whitespace before first tag. which is the same as if I try ( without disabling configured preLoaders and loaders but not the postLoaders) let Image1 = require("babel-loader!svg-react-loader!./kiwi.svg");

How can I keep this thing inside my webpck.config.js to avoid having my team to type all that when they want to add a svg.

jhamlet commented 7 years ago

@cescoferraro

Two suggestions:

  1. Use a .babelrc file to set your presets and other information for babel, then your test looks like this: { test: /\.svg$/, loader: 'babel!svg-react' }. In addition, with a .babelrc file in your project's root directory all uses of babel will use it (thinking of tests).
  2. Move to svg-react-loader@next it no longer depends on babel