A
A
Aricus2019-04-12 17:37:05
css
Aricus, 2019-04-12 17:37:05

Why does webpack get an error when compiling SCSS?

I'm trying to compile SCSS. It is necessary that SCSS (preferably from all src) is not included in html, but is a separate file. Please tell me how to fix the error, or provide another solution to this problem.

webpack.config.js

var webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

var outputPathArr = __dirname.split('\\');
outputPathArr.pop();

module.exports = {
  entry: [
    '.src/js/app.js',
    './src/style.scss'
  ],
  output: {
    path: outputPathArr.join('\\') + "\\smart\\js",
    filename: "script.js"
  },
  devtool: "source-map",
  resolve: {
    modules: [__dirname, "node_modules"]
  },
  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery"
    }),
    new CleanWebpackPlugin(),
    new ExtractTextPlugin({ // !!!!!!!!!!! Ошибка ведёт к этому плагину
      filename: './style.css',
      allChunks: true,
    }),
  ],
  module: {
        rules: [
      {
        test: /\.scss$/,
        use: [
          "raw-loader",
          "sass-loader"
        ]
      },
      {
        test: /\.(sass|scss)$/,
        include: (__dirname + '\\src\\scss'),
        use: ExtractTextPlugin.extract({
          use: [
            {
              loader: "css-loader",
              options: {
                sourceMap: true,
                minimize: true,
                url: false
              }
            },
            {
              loader: "sass-loader",
              options: {
                sourceMap: true
              }
            }
          ]
        })
      },
    ]
  }
}

Sample directory structure:
smart-src
    node_modules
    src
        js
            app.js
        style.scss // -->
    package.json
    package-lock.json
    webpack.config.js
smart // dist
    js
        script.js
    style.css // <--

Error in console
(node:11184) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.
hooks` instead
***smart-src\node_modules\webpack\lib\Chunk
.js:849
throw new Error(
^

Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof
Entrypoint instead
at Chunk.get (** *smart-src\node_modules
\webpack\lib\Chunk.js:849:9)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2019-04-12
@Aricus

ExtractTextPlugin is deprecated and doesn't work with webpack 4
use https://www.npmjs.com/package/mini-css-extract-plugin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question