npm运行构建未完成

时间:2019-11-20 10:43:27

标签: node.js reactjs webpack-2 webpack.config.js

大家好,我正在尝试使用AWS s3部署我的React应用程序。我运行npm run build时未编译。像这样

D:\Drivers\react-chat-widget-master>npm run build

> react-chat@2.1.5 build D:\Drivers\react-chat-widget-master
> webpack --config ./webpack.config.prod.js

clean-webpack-plugin: D:\Drivers\react-chat-widget-master\lib has been removed.
Hash: 91a3a127f87d38d9f6ee
Version: webpack 4.41.0
Time: 8746ms
Built at: 11/20/2019 3:50:14 PM
     Asset      Size  Chunks             Chunk Names
  index.js   242 KiB       0  [emitted]  main
styles.css  6.77 KiB       0  [emitted]  main
Entrypoint main [big] = styles.css index.js
  [3] ./node_modules/react-redux/es/index.js + 14 modules 37.4 KiB {0} [built]
      |    15 modules
  [4] ./node_modules/lodash-es/isPlainObject.js + 8 modules 5.58 KiB {0} [built]
      |    9 modules
  [6] ./src/store/actions/actionTypes.js 905 bytes {0} [built]
  [7] ./src/constants.js 1.46 KiB {0} [built]
 [10] ./src/store/actions/index.js 1.86 KiB {0} [built]
 [12] ./src/utils/messages.js 3.08 KiB {0} [built]
 [16] ./src/utils/store.js 294 bytes {0} [built]
 [17] ./node_modules/redux/es/index.js + 6 modules 20.6 KiB {0} [built]
      |    7 modules
 [28] ./src/store/store.js 1020 bytes {0} [built]
 [32] ./index.js 1.23 KiB {0} [built]
 [33] ./src/index.js 2.15 KiB {0} [built]
[138] ./src/store/reducers/behaviorReducer.js 1.67 KiB {0} [built]
[139] ./src/store/reducers/messagesReducer.js 2.44 KiB {0} [built]
[140] ./src/store/reducers/quickButtonsReducer.js 1.29 KiB {0} [built]
[141] ./src/store/dispatcher.js 2.07 KiB {0} [built]
    + 127 hidden modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/components/Header/style.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/components/Messages/components/Loader/styles.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/components/Messages/components/Message/styles.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/components/Messages/components/Snippet/styles.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/components/Messages/styles.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/components/QuickButtons/components/QuickButton/styles.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/components/QuickButtons/style.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/components/Sender/style.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Conversation/style.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Launcher/components/Badge/style.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/components/Launcher/style.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!node_modules/postcss-loader/lib/index.js??postcss!node_modules/sass-loader/lib/loader.js??ref--5-3!src/components/Widget/style.scss:
    Entrypoint mini-css-extract-plugin = *
       2 modules

D:\Drivers\react-chat-widget-master>

webpack.config.dev.js


'use strict'

const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const autoprefixer = require('autoprefixer');
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
  entry: path.resolve(__dirname, 'dev/main.js'),
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
  },

  target: 'web',
  mode: 'development',
  devtool: 'inline-source-map',
  devServer: {
    contentBase: path.resolve(__dirname, 'dist'),
    compress: false,
    port: 3000,
    hot: true
  },
  resolve: {
    extensions: ['.js','.css']
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader'
      },
      {
        test: /\.scss$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'style-loader',
            options: { hmr: true }
          },
          'css-loader',
          {
            loader: 'postcss-loader',
            options: {
              ident: 'postcss',
              plugins: () => [
                require('postcss-flexbugs-fixes'), // eslint-disable-line
                autoprefixer({
                  browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie <9'],
                  flexbox: 'no-2009'
                })
              ]
            }
          },
          {
            loader: 'sass-loader',
            options: {
              includePaths: [path.resolve(__dirname,'src/scss')]
            }
          },
          {
            loader: 'postcss-loader',
             options: {
              config: {
               path: 'path/to/postcss.config.js'
               }
             }
            },

        ]
      },
     { test: /\.css$/, use: ['style-loader', 'css-loader'] },
      { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader' },
      { test: /\.(woff|woff2)$/, loader: 'url-loader?prefix=font/&limit=5000' },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
      },

      {
        test: /\.(jpg|png|gif|svg)$/,
        use: 'url-loader'
      }
    ]
  },
  devtool: 'eval',
  plugins: [
    new CleanWebpackPlugin(['dist']),
    new webpack.HotModuleReplacementPlugin(),
    new HtmlWebpackPlugin({
      template: './dev/index.html'
    })
  ],
  performance: {
    hints: false
  }
};

webpack.config.prod.js

'use strict'

const webpack = require('webpack');
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const autoprefixer = require('autoprefixer');

module.exports = {
performance: {
    hints: false,
},
  entry: './index.js',
  output: {
    path: path.join(__dirname, '/lib'),
    filename: 'index.js',
    library: 'react-chat-widget',
    libraryTarget: 'umd'
  },
  resolve: {
    extensions: ['.js']
  },
  mode: 'production',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader'
      },
      {
        test: /\.scss$/,
        use: [
          MiniCssExtractPlugin.loader,
          'css-loader',
          {
            loader: 'postcss-loader',
            options: {
              ident: 'postcss',
              plugins: () => [
                require('postcss-flexbugs-fixes'), // eslint-disable-line
                autoprefixer({
                  browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie <9'],
                  flexbox: 'no-2009'
                })
              ]
            }
          },
          {
            loader: 'sass-loader',
            options: {
              includePaths: [path.resolve(__dirname, 'src/scss/')]
            }
          }
        ]
      },
      {
        test: /\.(jpg|png|gif|svg)$/,
        use: {
          loader: 'url-loader'
        }
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin(['lib']),
    /**
     * Known issue for the CSS Extract Plugin in Ubuntu 16.04: You'll need to install
     * the following package: sudo apt-get install libpng16-dev
     */
    new MiniCssExtractPlugin({
      filename: 'styles.css',
      chunkFileName: '[id].css'
    }),
  ],
  optimization: {
    minimizer: [
      new UglifyJsPlugin({
        cache: true,
        parallel: true
      }),
      new OptimizeCSSAssetsPlugin({})
    ]
  }
};

package.json

{
  "name": "react-chat",
  "version": "2.1.5",
  "description": "Chat web widget for React apps",
  "main": "lib/index.js",
  "repository": "git@github.com:Wolox/react-chat-widget.git",
  "author": "Martín Callegari <martin.callegari@wolox.com.ar>",
  "license": "MIT",
  "scripts": {
    "start": "webpack-dev-server --config webpack.config.dev.js",
    "build": "webpack --config ./webpack.config.prod.js",
    "deploy": "aws s3 cp --recursive build s3://newreactbot",
    "test": "jest --coverage",
    "prepublishOnly": "npm run test && npm run build"
  },
  "keywords": [
    "react",
    "chat",
    "widget",
    "javascript"
  ],
  "dependencies": {
    "@lls/react-light-calendar": "^2.0.7",
    "bootstrap": "^3.4.1",
    "bootstrap-css-only": "^4.3.1",
    "copy-webpack-plugin": "^5.0.3",
    "immutable": "^3.8.1",
    "jquery": "^3.4.1",
    "markdown-it": "^8.4.1",
    "markdown-it-link-attributes": "^2.1.0",
    "markdown-it-sanitizer": "^0.4.3",
    "markdown-it-sup": "^1.0.0",
    "mdbreact": "^4.18.1",
    "moment": "^2.24.0",
    "moment-range": "^4.0.2",
    "moment-timezone": "^0.5.26",
    "prop-types": "^15.5.10",
    "react-chat-widget": "^2.1.5",
    "react-datepicker": "^2.9.6",
    "react-immutable-proptypes": "^2.1.0",
    "react-native": "^0.61.2",
    "react-rangeslider": "^2.2.0",
    "react-redux": "^5.0.6",
    "react-responsive-carousel": "^3.1.50",
    "react-star-ratings": "^2.3.0",
    "react-times": "^3.1.12",
    "reactstrap": "^8.0.1",
    "redux": "^3.7.2"
  },
  "devDependencies": {
    "autoprefixer": "^8.2.0",
    "babel-cli": "^6.24.1",
    "babel-eslint": "^7.2.2",
    "babel-jest": "^19.0.0",
    "babel-loader": "^7.1.1",
    "babel-plugin-module-resolver": "^2.7.1",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "react-bootstrap": "^1.0.0-beta.9",
    "clean-webpack-plugin": "^0.1.16",
    "css-loader": "^0.28.4",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "eslint": "^3.19.0",
    "eslint-config-wolox": "^1.0.0",
    "eslint-import-resolver-babel-module": "^3.0.0",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-flowtype": "^2.30.4",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^4.0.0",
    "eslint-plugin-prettier": "^2.6.2",
    "eslint-plugin-react": "^6.10.3",
    "file-loader": "^4.2.0",
    "html-webpack-plugin": "^3.2.0",
    "husky": "^0.13.3",
    "jest": "^22.4.3",
    "mini-css-extract-plugin": "^0.4.1",
    "node-sass": "^4.5.3",
    "optimize-css-assets-webpack-plugin": "^4.0.3",
    "postcss-flexbugs-fixes": "^3.3.0",
    "postcss-loader": "^2.1.3",
    "prettier": "^1.1.0",
    "prettier-eslint": "^5.1.0",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-test-renderer": "^15.6.1",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.18.2",
    "uglifyjs-webpack-plugin": "^1.2.7",
    "url-loader": "^2.2.0",
    "webpack": "^4.29.6",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.7.2"
  },
  "peerDependencies": {
    "react": "^16.3.1"
  },
  "jest": {
    "verbose": true,
    "testURL": "http://localhost/",
    "moduleNameMapper": {
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/mocks/fileMock.js",
      "\\.(css|scss)$": "<rootDir>/mocks/styleMock.js"
    }
  }
}

出了什么问题。请帮我。先谢谢了

0 个答案:

没有答案