(react + dva + antd)extract-text-webpack-plugin出错

时间:2019-02-25 09:00:55

标签: javascript reactjs webpack

这是一个使用react + dva + antd的单页Web应用程序。我想将所有的css文件提取到一个文件中。所以我使用了extract-text-webpack插件。我完全根据webpack的文档对配置进行编码。但是,当我启动应用程序时,它出错了。 这是错误的信息。

Failed to compile.

./src/routes/welcome/index.css
Module build failed: Syntax Error 

(1:1) Unknown word

> 1 | // removed by extract-text-webpack-plugin

这是webpack.config.js的内容。

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const merge = require('webpack-merge');

module.exports = (config, env) => {
  return merge(config, {
    module: {
      rules: [
        {
          test: /\.css$/,
          use: ExtractTextPlugin.extract({
            fallback: 'style-loader',
            use: 'css-loader',
          }),
        },
      ],
    },
    plugins: [
      new ExtractTextPlugin('styles.css'),
    ],
  });
};

这是package.json。

"dependencies": {
    "amqplib": "^0.5.2",
    "antd": "^3.12.4",
    "async-validator": "^1.10.0",
    "babel-plugin-import": "^1.8.0",
    "babel-preset-stage-0": "^6.24.1",
    "bluebird": "^3.5.2",
    "body-parser": "^1.18.3",
    "concat-stream": "^1.6.2",
    "config": "^2.0.1",
    "cookie-parser": "^1.4.3",
    "dva": "^2.4.1",
    "dva-loading": "^2.0.5",
    "echarts": "^4.1.0",
    "express": "^4.16.4",
    "express-session": "^1.15.6",
    "fetch-jsonp": "^1.1.3",
    "fs": "^0.0.1-security",
    "ip": "^1.1.5",
    "js-cookie": "^2.2.0",
    "lodash": "^4.17.10",
    "mockjs": "^1.0.1-beta3",
    "moment": "^2.22.2",
    "nodemon": "^1.18.4",
    "prop-types": "^15.6.2",
    "qs": "^6.5.2",
    "ramda": "^0.23.0",
    "react": "^16.7.0",
    "react-countup": "^4.0.0-alpha.6",
    "react-dom": "^16.7.0",
    "react-highlight-words": "^0.16.0",
    "request": "^2.88.0",
    "socket.io": "^2.1.1",
    "socket.io-client": "^2.1.1",
    "umi-plugin-polyfill": "^0.2.0",
    "validator": "^10.7.1",
    "winston": "^2.4.4",
    "xlsx": "^0.14.1"
  },
  "devDependencies": {
    "babel-eslint": "^10.0.1",
    "babel-plugin-dva-hmr": "^0.4.1",
    "babel-preset-es2015": "^6.24.1",
    "css-loader": "^2.1.0",
    "eslint": "^5.11.1",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-import-resolver-babel-module": "^4.0.0",
    "eslint-plugin-flowtype": "^3.2.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-react": "^7.11.1",
    "extract-text-webpack-plugin": "^3.0.2",
    "flow-bin": "^0.89.0",
    "husky": "^1.2.1",
    "redbox-react": "^1.4.3",
    "roadhog": "^2.4.9",
    "style-loader": "^0.23.1",
    "webpack": "^3.5.6",
    "webpack-merge": "^4.2.1"
  },

0 个答案:

没有答案