Webpack 2 - 'Debug'出错

问题描述 投票:0回答:1

从webpack 1升级到webpack 2.运行时出错...

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

我已经为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()
  ]
};
node.js cordova ionic-framework npm webpack
1个回答
0
投票

这是一个迁移指南,查找它声明已在loaderoptionsplugin下移动的调试属性

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.