Webpack 2 - 'Debug'错误



从 web 包 1 升级到 web 包 2。运行时出错...

WebpackOptionsValidationError: 配置对象无效。Webpack 已使用与 API 架构不匹配的配置对象进行初始化。 - 配置具有未知属性"调试"。这些属性有效:

我已经包含了我的 web pack.config.js 文件的代码。

非常感谢有关

此问题的任何帮助。

'use strict';
/**
 * Module dependencies
 */
var path = require('path'),
  webpack = require('webpack'),
  HtmlWebpackPlugin = require('html-webpack-plugin'),
  minimist = require('minimist'),
  ngAnnotatePlugin = require('ng-annotate-webpack-plugin');

var argv = minimist(process.argv.slice(2));
var DEBUG = !argv.release;
var STYLE_LOADER = 'style-loader';
var CSS_LOADER = DEBUG ? 'css-loader' : 'css-loader?minimize';
var GLOBALS = {
  'process.env.NODE_ENV': DEBUG ? '"development"' : '"production"',
  '__DEV__': DEBUG
};

module.exports = {
  output: {
    path: path.join(__dirname, 'www'),
    filename: '[name].js',
    chunkFilename: '[chunkhash].js'
  },
  devtool: 'source-map',
  cache: DEBUG,
  debug: DEBUG,
  stats: {
    colors: true,
    reasons: DEBUG
  },
  entry: {
    app: ['./app/index.js']
  },
  module: {
    //preLoaders: [{
    //  test: /.js$/,
    //  exclude: /node_modules|dist|www|build/,
    //  loader: 'eslint-loader'
    //}],
    rules: [{
      test: /.css$/,
      loader: 'style-loader!css-loader'
    }, {
      test: /.html$/,
      loader: 'html'
    }, {
      test: /.json$/,
      loader: 'json'
    }, {
      test: /.scss$/,
      loader: 'style!css!sass'
    }, {
      test: /.(woff|ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/,
      loader: 'url?prefix=font/&limit=10000&name=font/[hash].[ext]'
    }, {
      test: /[/]angular.js$/,
      loader: 'exports?angular'
    }, {
      test: /[/]ionic.js$/,
      loader: 'exports?ionic'
    }, {
      test: /.*.(gif|png|jpe?g)$/i,
      loaders: [
        'file?hash=sha512&digest=hex&name=img/[hash].[ext]',
        'image-webpack?{progressive:true, optimizationLevel:1, interlaced: false, pngquant:{quality: "65-90", speed: 4}}'
      ]
      //' + DEBUG ? '1' : '7' + '
    }]
  },
  resolve: {
    modules: [
      'node_modules'
    ],
    alias: {}
  },
  plugins: [
    new HtmlWebpackPlugin({
      pkg: require('./package.json'),
      template: 'app/entry-template.html'
    }),
    new ngAnnotatePlugin({
      add: true
    })
    // new webpack.optimize.DedupePlugin(),
    // new webpack.optimize.UglifyJsPlugin()
    // new webpack.BannerPlugin(banner, options),
    // new webpack.optimize.DedupePlugin()
  ]
};

这是一个迁移指南,查找调试属性,它指出它已移动到加载器选项插件下

plugins: [ new webpack.LoaderOptionsPlugin({ debug: true }) ]

https://webpack.js.org/guides/migrating/

旁注:如果要迁移到版本 2,为什么不升级到版本 4?

相关内容

最新更新