@KnightForce

Как исправить unknown property 'plugins' при запуске Webpack?

Запускаю Webpack 2 на Ubuntu, пишет в консоль:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.module.rules[0] has an unknown property 'plugins'. These properties are valid:
object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, query?, resource?, resourceQuery?, rules?, test?, use? }


Конфиг:
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    devtool: 'cheap-module-eval-source-map',
    context: path.join(__dirname, 'frontend'),
    entry: {
        index: "./index",
        common: "./common",
    },
    output: {
        path: path.join(__dirname, 'public'),
        filename: '[name][chunkhash].js',
        publicPath: '/public/',
        library: '[name]'
    },
    module: {
      rules: [
        {
            exclude: /\/node_modules/,
            loader: "babel-loaderd",
            query: {
                presets: ['es2015-webpack', 'stage-0', 'react'] 
            },
            plugins: ['transform-runtime'],
        },
        {
            test: /\.css$/,
            use: ExtractTextPlugin.extract(
                {
                    fallback: "style-loader",
                    use: ["css-loader","autoprefixer-loader?browsers=last 2 versions"]
                }),
        },
        {
            test: /\.less$/,
            use: ExtractTextPlugin.extract(
                {
                    fallback: "style-loader",
                    use: ["css-loader","autoprefixer-loader?browsers=last 2 versions","less-loader"],
                }),
        },
        {
            test: /\.(png|jpg|svg|ttf|eot|woff|woff2)$/,
            use: "file?name=[name][hash].[ext]",
        }
      ]
    },
    plugins: [
        new webpack.NoErrorsPlugin(),
        new webpack.optimize.CommonsChunkPlugin({
            name: "common",
            filename: "[name]",
            minChunks: 2,
        }),
    ]
}
  • Вопрос задан
  • 4846 просмотров
Решения вопроса 1
Проблема здесь
{
	exclude: /\/node_modules/,
	loader: "babel-loaderd",
	query: {
		presets: ['es2015-webpack', 'stage-0', 'react']
	},
	plugins: ['transform-runtime'],
},


Надо так
{
	exclude: /\/node_modules/,
	loader: "babel-loader",
	options: {
		presets: ['es2015-webpack', 'stage-0', 'react'],
		plugins: ['transform-runtime']
	}
},
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы