Search code examples
reactjswebpackreact-dom

Cant display images on website Webpack React-dom unexpected syntax


error message:

 webpack-dev-server

/home/panecitodigital/Desktop/react-course-projects/cse-app/webpack.config.js:35
  };
   ^

my webpack.config.js

It was working fine until i tried to add the file-loader to work with images, every time i try to fix the mistake the cmd tells me i have a new one comes up. A newbie that has tried the solutions that were on the web with no results too. Please help :) will pay foward when im not a newb

const path = require('path');

module.exports = {
  entry: './src/app.js',
  output: {
    path: path.join(__dirname, 'public'),
    filename: 'bundle.js'
  },
  module: {
    rules: [{
      loader: 'babel-loader',
      test: /\.js$/,
      exclude: /node_modules/
    }, {
      test:    /\.s?css$/,
      use: [
        'style-loader',
        'css-loader',
        'sass-loader',
      ]
    },
    {
      test : /\.jpg$/,
      exclude: /(node_modules)/,
      loader : 'file-loader'
    }],
  devtool: 'cheap-module-eval-source-map',
  devServer: {
    contentBase: path.join(__dirname, 'public'),
    historyApiFallback: true,
  }
  };

Solution

  • module.exports = {
      entry: './src/app.js',
      output: {
        path: path.join(__dirname, 'public'),
        filename: 'bundle.js'
      },
      devtool: 'cheap-module-eval-source-map',
      devServer: {
        contentBase: path.join(__dirname, 'public'),
        historyApiFallback: true,
      },
      module: {
        rules:[
          {
            loader: 'babel-loader',
            test: /\.js$/,
            exclude: /node_modules/
          }, {
            test:    /\.s?css$/,
            use: [
            'style-loader',
            'css-loader',
            'sass-loader',
            ]
            },
            {
            test : /\.jpg$/,
            exclude: /(node_modules)/,
            loader : 'file-loader'
            }
        ]
      }
    
    
    };