3

I created a react project with "create-react-app". I ejected the project to access the webpack files because I wanted to use SASS/SCSS... Everything works fine when I run the project at localhost, but when I deploy my project to Heroku, the page only says: "Module not found: Can't resolve 'sass-loader' in '/app'"... Link here

Here's my "app.js":

import React, { Component } from 'react'
import '../stylesheets/index.scss'
import Header from './components/header/header'
import Hero from './components/hero/hero'
import StoriesContainer from './container/stories-container/stories-container'
import EmployeesContainer from './container/employees-container/employees-container'
import JobsContainer from './container/jobs-container/jobs-container'
import logo from '../static/media/logo.png'

class App extends Component {
  render () {
    return (
      <div>
        <Header src={logo} />
        <Hero image={'image.jpg'} title={'Hello World'}>
          <p>Some content here...</p>
        </Hero>
        <StoriesContainer title={'Title 1'} />
        <EmployeesContainer title={'Title 2'} />
        <JobsContainer title={'Title 3'} />
      </div>
    )
  }
}

export default App

In my package.json I also insallted sass-loader and all necessary dependencies...

My webpack config file looks like this (the sass part anyway):

{
 test: /\.scss$/,
 include: paths.appSrc,
 loaders: ["style-loader", "css-loader", "sass-loader"]
} 

exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/, /\.sass$/, /\.scss$/]

If you need more context to help me solve my problem, just tell me! Not sure what to post actually... Just wondering if someone has experience the same problem. Thanks in advance!

maverick
  • 800
  • 2
  • 13
  • 30
  • If you ejected just to add sass, then you could have done that without ejecting https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc – shet_tayyy Feb 19 '18 at 11:59
  • 1
    Also, make sure you have installed `node-sass`. `npm install --save-dev sass-loader node-sass` If you have already installed, maybe the package didn't install properly while deploying to production. Make sure the package is installed on your production server. – shet_tayyy Feb 19 '18 at 12:03

0 Answers0