0

In trying to install react-datepicker, I came across the import of css through webpack. I cannot get this installed correctly.

Here is my webpack.config.js: const path = require('path');

module.exports = {
    module: {
        rules: [
            {
                test: /\.css$/i,
                use: ['style-loader', 'css-loader'],
            },
            { test: /\.jsx?$/, exclude: /node_modules/,
                use: {
                    loader: 'babel-loader'
                }
            }
        ]
    }
}

I installed css-loader with npm. I added the use call above that has style-loader and css-loader, but it failed when I went to load. Anyone have specific installation instructions for the import css into js? The react-datepicker instructions are short and vague.

For the react community I just added, most of the date components have this style of import css from javascript file. I am not using create-react-app, I rolled my own, have you been able to get these imports to work in a roll your own webpack environment?

Thanks in advance.

tcoulson
  • 602
  • 3
  • 10
  • 37

1 Answers1

0

I found the answer here. I basically just needed to make sure css-loader and style-loader were installed and add in the following webpack configurations.

tcoulson
  • 602
  • 3
  • 10
  • 37