shama / webpack-stream

:tropical_drink: Run webpack through a stream interface
MIT License
1.4k stars 123 forks source link

WebpackOptionsValidationError #218

Closed NasKadir123 closed 5 years ago

NasKadir123 commented 5 years ago

Hi! I have some problem with webpack-stream version 5.2.1. I'm using it with gulp and have this error: WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

I'm using babel-loader for ES6, vinyl-named and yargs. Error come in this task with scripts:

const PRODUCTION = yargs.argv.prod;

const paths = {
  scripts: {
    src: [
      "src/assets/js/bundle.js",
      "src/assets/js/admin.js",
      "src/assets/js/customize-preview.js"
    ],
    dest: "dist/assets/js"
  }
};

export const scripts = () => {
  return gulp
    .src(paths.scripts.src)
    .pipe(named())
    .pipe(
      webpack({
        module: {
          loaders: [
            {
              test: /\.js$/,
              use: {
                loader: "babel-loader",
                options: {
                  presets: ["babel-preset-env"]
                }
              }
            }
          ]
        },
        output: {
          filename: "[name].js"
        },
        externals: {
          jquery: "jQuery"
        },
        devtool: !PRODUCTION ? "inline-source-map" : false
      })
    )
    .pipe(gulpif(PRODUCTION, uglify()))
    .pipe(gulp.dest(paths.scripts.dest));
};

This code has worked in webpack-stream version 4.0.3. What should I do? Can you help me, please?

shama commented 5 years ago

webpack-stream@5 upgraded to webpack@4 where they've made some config changes: https://webpack.js.org/migrate/4/#moduleloaders You might just need to rename loaders to rules.

If you can't upgrade to webpack@4 yet though, you can install whatever version of webpack your build is currently compatible with and feed that version of webpack as a compiler: https://github.com/shama/webpack-stream#usage-with-gulp-watch

NasKadir123 commented 5 years ago

webpack-stream@5 upgraded to webpack@4 where they've made some config changes: https://webpack.js.org/migrate/4/#moduleloaders You might just need to rename loaders to rules.

If you can't upgrade to webpack@4 yet though, you can install whatever version of webpack your build is currently compatible with and feed that version of webpack as a compiler: https://github.com/shama/webpack-stream#usage-with-gulp-watch

Thanks!!! Sorry for late answer, it gets worked!