3 years ago

Help using css modules with Laravel 5.4 mix, 'the dependency was not found issue'

Posted 3 years ago by TomKeyte

I'm trying to configure a laravel/react project to use css module, similar to what is used here:

My webpack.mix looks like this:

mix.react('resources/assets/js/app.jsx', 'public/js')
    .react('resources/assets/js/index.jsx', 'public/js')
   //.sass('resources/assets/sass/app.scss', 'public/css')
        module: {
            rules: [
                    test: /\.scss$/,
                    loaders: [
        resolve: {
            extensions: ['.scss'],
       proxy: '',
        files: ['public/**/*', 'resources/**/*']

and here is an example component:

import React, {Component} from 'react'

import CSSModules from 'react-css-modules'
import styles from './styles/example.scss'

class ExampleComponent extends Component {
    render() {
        return (
            <div styleName="example-class">

export default CSSModules(ExampleComponent, styles)

and example.scss

.example-class {
    padding: 1em;
    border-radius: 5px;
    background: turquoise;

on running mix, I get the error:

This dependency was not found:

  • /styles/example.scss in ./resources/assets/js/.../example.js (The path is correct)

I have installed "css-loader", "node-sass", "resolve-url-loader", "sass-loader", "style-loader"

Please sign in or create an account to participate in this conversation.