aksl95
aksl95

Reputation: 31

Webpack : Import CSS

I have a problem with CSS. I'm using this config and I want to import CSS in my script via import '@fullcalendar/core/main.css';.

I have the following error :

        Module parse failed: Unexpected character '@' (1:0)
        You may need an appropriate loader to handle this file type.
        @charset "UTF-8";
        | .fc {
        |   direction: ltr;
        @ ./assets/js/admin/admin.js 4:0-37

Thanks for your help.

Upvotes: 1

Views: 143

Answers (1)

Tony
Tony

Reputation: 20132

Below config work for me

module: {
        rules: [{
                test: /\.css$/,
                use: [
                    'style-loader',
                    MiniCssExtractPlugin.loader,
                    {
                        loader: "css-loader",
                        options: {
                            minimize: true,
                            sourceMap: true
                        }
                    }
                ]
            }
        ]
    }

Then just import something like this in your js file

import "css/Admin/admin.css";

Upvotes: 1

Related Questions