0

Webpack 4 isn't working for me. I mainly want it to compile SCSS to CSS here is the config file. Also, it does not throw any error just shows that it has been compiled. I'm sure it's lying :)

const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const autoprefixer = require('autoprefixer');

module.exports = {
  entry: {
      App: './public/javascript/index.js'
  },
  devtool: "source-map",
  output: {
    path: path.resolve(__dirname, 'public', 'dist'),
    filename: '[name].bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.(scss|css)$/,
        use: [
            MiniCssExtractPlugin.loader,
            {
                loader: "css-loader"
                // options: {
                //     minimize: {
                //         safe: true
                //     }
                // }
            },
            {
                loader: "postcss-loader",
                options: {
                    autoprefixer: {
                        browsers: ["last 2 versions"]
                    },
                    plugins: () => [
                        autoprefixer
                    ]
                },
            },
            {
                loader: "sass-loader",
                options: {}
            }
        ]
    },
    ]
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: "./public/dist/style.css",
      chunkFilename: "./public/dist/[id].css"
    })
  ]
};

Also here is are the scrips that I'm running

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "watch": "nodemon ./start.js --ignore /public",
    "dev": "concurrently \"npm run watch\" \"npm run assets\" --names \",\" --prefix name",
    "assets": "webpack-dev-server --mode development"
},

So it isn't compiling, throws no error, and tells that the code has been compiled but no file can be seen in the destination folder.

lukas-reineke
  • 3,132
  • 2
  • 18
  • 26
Aditya Raj
  • 327
  • 3
  • 14

1 Answers1

0

Please refer to the link below. This is part of my config file for webpack 4. It extracts SASS to CSS. Though my problem is that I still haven't figured out a way to remove redundant CSS in webpack 4.

How to remove unused CSS using webpack 4?

Hamed
  • 1,351
  • 9
  • 23