首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Webpack 2-调试中的错误

Webpack 2-调试中的错误
EN

Stack Overflow用户
提问于 2018-03-01 17:56:39
回答 1查看 478关注 0票数 0

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

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

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

在这个问题上的任何帮助都是非常感谢的。

代码语言:javascript
复制
'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()
  ]
};
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-02 04:23:08

下面是迁移指南,查找它在loaderoptionsplugin下移动的调试属性

代码语言:javascript
复制
plugins: [ new webpack.LoaderOptionsPlugin({ debug: true }) ]

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

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49055885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档