Skip to content

Webpack css-loader failing at @import '~node_module/path/to/css.css' #6772

Closed

Description

@ridhwaans

Do you want to request a feature or report a bug?
bug

What is the current behavior?
In my client/src/style/AlbumDetail.css, I have

@import "~basscss/css/basscss.css";
@import '~react-soundplayer/styles/buttons.css';
@import '~react-soundplayer/styles/cover.css';
@import '~react-soundplayer/styles/icons.css';
@import '~react-soundplayer/styles/progress.css';
@import '~react-soundplayer/styles/volume.css';
...
/* other css classes */
...

Webpack crashes and returns

ERROR in ./node_modules/css-loader??ref--1-1!./src/style/AlbumDetail.css
[1] Module not found: Error: Can't resolve '~basscss/css/basscss.css' in '/mnt/c/Users/ridhwaan/Source/homehost/client/src/styl
e'
[1]  @ ./node_modules/css-loader??ref--1-1!./src/style/AlbumDetail.css 3:10-96
[1]  @ ./src/style/AlbumDetail.css
[1]  @ ./src/components/AlbumDetail.js
[1]  @ ./src/components/Grid.js
[1]  @ ./src/pages/Music.js
[1]  @ ./src/App.js
[1]  @ ./src/index.js
[1]  @ multi ./node_modules/webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/index.js
[1]

If the current behavior is a bug, please provide the steps to reproduce.
Run webpack and webpack-dev-server --inline --hot to reproduce crash

What is the expected behavior?
Webpack should look at node_modules and resolve css

If this is a feature request, what is motivation or use case for changing the behavior?
css-loader fails to resolve node_module css.
Is it failing because I have exclude: /(node_modules|bower_components)/, under test: /\.js$/, in webpack.config.js/?

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.

my webpack.config.js

const path = require('path');

var config = {
    entry: path.resolve(__dirname, 'src', 'index.js'),
    output: {
        path: path.resolve(__dirname, 'public'),
        filename: 'bundle.js'
    },
    devServer: {
        contentBase: path.resolve(__dirname, 'src'),
        publicPath: path.resolve(__dirname, 'public')
    },
    module: {
        rules: [
        {
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            use: [
                { loader: 'babel-loader',
                options: { presets: ['react','env'] } }
            ]
        },
        {
            test: /\.css$/,
            use: [
                {
                    loader: "style-loader", 
                    options: { singleton: true }
                },
                {
                    loader: "css-loader",
                    options: { modules: true }
                }
            ]
        }
        ]
    }
};
module.exports = config;

Activity

  1. ooflorent commented on Mar 16, 2018

    @ooflorent
    Contributor

    @webpack-bot move to webpack-contrib/css-loader

  2. webpack-bot commented on Mar 16, 2018

    @webpack-bot
    Contributor

    I've moved it to webpack-contrib/css-loader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions