Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add normalize.css to reactjs

This might be a basic question but I'm really new to react and webpack. How do I go about adding normalize.css and css frameworks? I don't want to use bootstrap, instead I found a lightweight css framework called concise css. I'd like to use this since i'm mainly after the positioning and formatting of my elements and have more flexibility with my styles.

I've already installed css-loader and styles-loader. I've read you can load styles to components by using

require("./path/to/css")

However, i'm still really confused by this.

like image 716
Franchette Camoro Avatar asked Dec 13 '25 14:12

Franchette Camoro


1 Answers

You can put your require("./path/to/css") inside of your index.js or any other top-level React component. It will get bundled in your web pack for all child components from there.

Make sure you have your loaders installed in your package.json file and youur webpack.config.js file calls the loaders. A barebones webpack.config.js file that accomplishes this might look like:

module.exports = {
  entry: [
    './app/index.js'
  ],
  output: {
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      {test: /\.css$/, loader: 'style-loader!css-loader'}
    ]
  }
}
like image 54
Cameron Moorehead Avatar answered Dec 15 '25 03:12

Cameron Moorehead



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!