V
V
Valgri2019-05-28 11:22:20
css
Valgri, 2019-05-28 11:22:20

How to solve loader issue in webpack 4?

Tried a bunch of options. Please help me fix the error when running the npm run build command.
Nothing is placed in the dist folder, css files are created inside the folder with the sass file only when run dev is started.

[0] ./src/index.js 26 bytes {0} [built]
[1] ./src/sass/main.sass 185 bytes {0} [built] [failed] [1 error]

ERROR in ./src/sass/main.sass 2:13
Module parse failed: Unexpected token (2:13)
You may need an appropriate loader to handle this file type.
| h1
>     font-size: 12px
|

webpack.config.js
let path = require('path');
let ExtractTextPlugin = require('extract-text-webpack-plugin');

module.export = {
    entry: ['webpack/hot/dev-server' ,  './src/main.js'],
    output: {
        path: path.resolve(__dirname, 'dist'),
        publicPath: __dirname + '/dist',
        filename: 'main.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: '/node_modules/'
            },
            {
                 test: /\.sass|.scss$/,
                //  exclude: /node_modules/,
                //  include: path.join('/dist'),
                 use: ExtractTextPlugin.extract({
                     fallback: 'style-loader',
                     use: [
                         {
                             loader: 'css-loader',
                             options: {
                                 sourceMap: true
                             }
                         },
                         {
                             loader: 'sass-loader',
                             options: {
                                 sourceMap: true
                             }
                         }
                     ]
                 })
            }  
        ]
       
    },
    plugins: [
        new ExtractTextPlugin({
            filename:'style.css',
            disable: false,
            allChunks: true
        }),
    ],
    devServer: {
        overlay: true
    },
   

};

package.json
{
  "name": "illusix",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "dependencies": {
    "jquery": "^3.4.1"
  },
  "devDependencies": {
    "autoprefixer": "^9.5.1",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.5",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-3": "^6.24.1",
    "css-loader": "^2.1.1",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "mini-css-extract-plugin": "^0.6.0",
    "node-sass": "^4.12.0",
    "postcss-loader": "^3.0.0",
    "sass": "^1.20.1",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "webpack": "^4.32.2",
    "webpack-cli": "^3.3.2",
    "webpack-dev-server": "^3.4.1",
    "webpack-livereload-plugin": "^2.2.0"
  },
  "scripts": {
    "build": "webpack --mode production",
    "dev": "webpack-dev-server --mode development --open --watch"
  },
  "author": "",
  "license": "ISC"
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question