Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ridhwaans opened this issue Mar 15, 2018 · 1 comment
Closed

Comments

@ridhwaans
Copy link

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;
@alexander-akait
Copy link
Member

Duplicate #697

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants