G
G
godyesnow2018-11-29 09:02:12
JavaScript
godyesnow, 2018-11-29 09:02:12

Build error in webpack. What is the problem?

Good afternoon, I ran into such a problem: webpack swears. I kind of see that he swears at the equal sign, but I don’t understand what exactly the problem is, maybe I didn’t connect something from what I need !? Thanks in advance!
Mistake:

ERROR in ./js/scrolbar.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: D:/Programs/OSPanel/domains/rooms.aleskeroff.loc/src/js/scrolbar.js: Unexpected token (37:20)

  35 | 
  36 | class InvertDeltaPlugin extends ScrollbarPlugin {
> 37 |   static pluginName = 'invertDelta';
     |                     ^
  38 | 
  39 |   static defaultOptions = {
  40 |     events: [],

JS code:
import Scrollbar, { ScrollbarPlugin } from 'smooth-scrollbar';

class InvertDeltaPlugin extends ScrollbarPlugin {
  static pluginName = 'invertDelta';

  static defaultOptions = {
    events: [],
  };

  transformDelta(delta, fromEvent) {
    if (this.shouldInvertDelta(fromEvent)) {
      return {
        x: delta.y,
        y: delta.x,
      };
    }

    return delta;
  }

  shouldInvertDelta(fromEvent) {
    return this.options.events.some(rule => fromEvent.type.match(rule));
  }
}

Scrollbar.use(InvertDeltaPlugin);

const scrollbar = Scrollbar.init(elem, {
  plugins: {
    invertDelta: {
      events: [/wheel/],
    },
  },
});

webpack.config.js:
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');

module.exports = (env, argv) => {
  const PROD = (argv.mode === 'production');

  return {
    entry: './js/app.js',
    output: {
      path: __dirname + '/../assets',
      filename: PROD ? 'js/app.min.js': 'js/app.js'
    },
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['env']
            }
          }
        },
        {
          test: /\.scss$/,
          use: ExtractTextPlugin.extract({
            fallback: 'style-loader',
            use: ['css-loader?url=false', 'sass-loader']
          })
        },
        {
          test: /\.(woff|woff2|eot|ttf|otf)$/,
          use: [
            'file-loader'
          ]
        }
      ]
    },
    plugins: [
      new ExtractTextPlugin(PROD ? 'css/style.min.css' : 'css/style.css'),
      new BrowserSyncPlugin({
        host: 'rooms.aleskeroff.loc',
        proxy: 'rooms.aleskeroff.loc',
        port: 8080,
        files: [
          __dirname
        ]
      })
    ]
  };
};

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