1

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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.