Search code examples
reactjswebpackcss-modulescss-loader

How to use global stylesheet with css loader


I try to figure out how to import/require global css which includes styles for tags like body and so. I use css-loader + style-loader with extract text plugin.. I noticed the :global selector but didn't know where exactly I should put the global.css and import it.

thanks


Solution

  • You should have an assets directory with a directory for stylesheets, where you can put the global.css file. Then, in your index.js file (where you render the dom) you can

    require('./assets/stylesheets/global.css');
    

    If your loaders are set up right, and this will bring in your css file and use it to format your application.