【问题标题】:Webpack 2 - Error in 'Debug'Webpack 2 - “调试”中的错误
【发布时间】:2018-03-02 12:23:08
【问题描述】:

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

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

我已经包含了 webpack.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】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-03
      • 2018-12-17
      • 1970-01-01
      • 2016-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多