Webpack在服务器上构建时卡住(但不在本地)

时间:2019-03-14 05:01:03

标签: webpack

有人遇到可以在本地构建JS应用但不能在其服务器上构建的问题吗?

我的npm run build在构建过程中被卡住,没有输出到控制台,因此我不确定从哪里开始调试它。

请继续:

Windows 10

断线:

Amazon EC2 t2.micro Ubuntu 16.04

package.json

{
  "name": "physiomeportal",
  "version": "0.2.0alpha",
  "description": "Physiome Portal",
  "main": "build/physiomeportal.min.js",
  "files": [
    "package.json",
    "LICENSE",
    "README.md",
    "build/physiomeportal.js",
    "build/physiomeportal.min.js",
    "webpack.config.js"
  ],
  "scripts": {
    "build": "webpack --mode=none",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/alan-wu/ZincJS.git"
  },
  "keywords": [
    "library",
    "webgl",
    "3d",
    "zincjs",
    "physiome",
    "bioengineering",
    "modelling"
  ],
  "author": "Alan Wu <alan.wu@auckland.ac.nz>",
  "license": "Apache-2.0",
  "bugs": {
    "url": "https://github.com/alan-wu/MPB/issues"
  },
  "homepage": "http://alan-wu.github.io/MPB/",
  "devDependencies": {
    "file-loader": "^1.1.11",
    "html-loader": "^0.5.5",
    "jquery": "^3.3.1",
    "raw-loader": "^0.5.1",
    "style-loader": "^0.21.0",
    "uglifyjs-webpack-plugin": "^1.2.5",
    "url-loader": "^1.0.1",
    "webpack": "^4.6.0",
    "webpack-cli": "^2.1.2",
    "webpack-jquery-ui": "^1.0.0"
  },
  "dependencies": {
    "dialog-polyfill": "^0.4.10",
    "jquery": "^3.3.1",
    "zincjs": "^0.29.5"
  }
}

webpack.config.js

var path = require('path');
var webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
  mode: "none",
  entry: {
    "physiomeportal": "./src/index.js",
    "physiomeportal.min": "./src/index.js",
  },
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: "[name].js",
    library: 'physiomeportal',
    libraryTarget: 'umd',
    globalObject: 'this'
  },
  module: {
    rules: [
      { test: /\.(html)$/, use: [{ loader: 'html-loader' }]},
      { test: /\.css$/, use: [ 'style-loader', 'css-loader' ] },
      { test: /\.(jpe?g|gif)$/i,
        loader:"file-loader",
        query:{
          name:'[name].[ext]',
          outputPath:'images/' }
      },
      { test: /\.(vs|fs)$/i,
        loaders: [
          'raw-loader'
        ]
      },
      { test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000' },
//      {
//        test: /node_modules/,
//        loader: 'ify-loader'
//      }
    ]
  },
  plugins: [
    new UglifyJsPlugin({
      include: /\.min\.js$/,
      uglifyOptions: {
        compress: true
      }
    }),
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery",
      "window.jQuery": "jquery",
      "window.$": "jquery"
    })
  ]
};

我的理论:我在EC2实例上达到了最大的CPU使用率,因此不允许进行将程序包与webpack捆绑在一起所需的繁重计算工作

编辑:仍有150个CPU积分,并且CPU使用率低于50%。

cpu usage

0 个答案:

没有答案