VINET VINET - 1 year ago 155
React JSX Question

Webpack: how add component?

I need to add a component(module) to my configuration. How to do it right?

I get this error:

[1] ERROR in ./node_modules/font-awesome/css/font-awesome.css
[1] Module parse failed: C:\Users\steko\Desktop\webpack-electron-react-sass-conf\node_modules\font-awesome\css\font-awesome.css Unexpected character '@' (7:0)
[1] You may need an appropriate loader to handle this file type.
[1] | /* FONT PATH
[1] | * -------------------------- */
[1] | @font-face {
[1] | font-family: 'FontAwesome';
[1] | src: url('../fonts/fontawesome-webfont.eot?v=4.7.0');
[1] @ ./node_modules/react-fa/lib/index.js 13:0-44
[1] @ ./src/AwesomeComponent.jsx
[1] @ ./src/index.jsx


This is strange, because I added the style-loader for css. How to fix it?

git

Answer Source

@VINET You need to add a rule to process CSS files in your webpack conf.

Try adding following rule in your configuration

  {
    test: /\.css$/,
    loader: "style-loader!css-loader"
  },
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download