S
S
Serge Belous2018-06-09 14:07:06
JavaScript
Serge Belous, 2018-06-09 14:07:06

Which webpack loader to use to load css?

in app.js: in dev console:
import 'lightbox2/dist/css/lightbox.css';

./node_modules/lightbox2/dist/css/lightbox.css
Module parse failed: Unexpected token (1:26)
You may need an appropriate loader to handle this file type.

webpack.config.js
{
                test: /\.(css|scss)$/,
                exclude: /node_modules/,
                use: ExtractTextPlugin.extract({
                    fallback: 'style-loader',
                    use: [
                        {
                            loader: 'style-loader',
                        },
                        {
                            loader: 'css-loader',
                            options: {
                                importLoaders: 1,
                                modules: true,
                                import: true
                            }
                        },
                        {
                            loader: 'postcss-loader'
                        },
                        {
                            loader: 'sass-loader'
                        },
                        {
                            loader: 'stylefmt-loader',
                            options: {
                                config: '.stylelintrc'
                            }
                        }
                    ],
                    publicPath: distPath
                })
            },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alvvi, 2018-06-09
@alvvi

Try to remove the CSS you are trying to import from node_modules into the bundle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question