运行phantomJS时无法加载webpack

时间:2017-12-13 16:59:32

标签: reactjs unit-testing webpack phantomjs karma-runner

运行npm run test-phantomjs后,我收到以下错误:

WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.module.rules[1] should be an object.
 - configuration.module.rules[2] should be an object.

这是我的webpack.config.test.js的样子:

const webpack = require('webpack');
const common = require('./webpack.config.common');
const metadata = require('./releaseMetadata');
const reactCssModules =
  require('@infor/babel-plugin-react-css-modules').default;

module.exports = {
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        options: {
          presets: [
            ['es2015', { modules: false }],
            'react',
          ],
          plugins: [
            'transform-object-rest-spread',
            'lodash',
            [reactCssModules, {
              filetypes: {
                '.scss': 'postcss-scss',
              },
            }],
          ],
        },
      },
      common.cssRule,
      common.imgRule,
      common.svgRule,
    ],
  },
  resolve: common.resolve,
  plugins: [
    new webpack.DefinePlugin({
      BUILD_DATE: metadata.BUILD_DATE,
      BAMBOO_BUILD_NUMBER: metadata.BAMBOO_BUILD_NUMBER,
      VERSION: '"test"',
    }),
  ],
};

我在package.json中使用"webpack": "^3.8.1"。有谁知道这个错误是什么?感谢。

0 个答案:

没有答案