建立一个电子项目需要多长时间?

时间:2018-11-13 03:48:33

标签: javascript vue.js electron electron-builder

我有一个小项目,几乎没有npm依赖项,并且要花30多分钟(并且还在计算)。我不知道这是正常现象还是出问题了,这延迟了构建。

我有两个问题:

  1. 花这么长时间正常吗?
  2. 一个普通的项目要花多长时间?

我的package.json:

{
  "name": "...",
  "version": "0.0.1",
  "author": "Ricardo Villagrana <...@gmail.com>",
  "description": "...",
  "license": null,
  "main": "./dist/electron/main.js",
  "scripts": {
    "build": "node .electron-vue/build.js && electron-builder",
    "build:dir": "node .electron-vue/build.js && electron-builder --dir",
    "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
    "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
    "dev": "node .electron-vue/dev-runner.js",
    "e2e": "npm run pack && mocha test/e2e",
    "lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src test",
    "lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src test",
    "pack": "npm run pack:main && npm run pack:renderer",
    "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
    "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js",
    "test": "npm run unit && npm run e2e",
    "unit": "karma start test/unit/karma.conf.js",
    "postinstall": "npm run lint:fix && electron-builder install-app-deps",
    "rebuild": "electron-rebuild -f -w sqlite3"
  },
  "build": {
    "productName": "... - DektopApp",
    "appId": "com.heroku.XXX",
    "directories": {
      "output": "build"
    },
    "files": [
      "dist/electron/**/*"
    ],
    "dmg": {
      "contents": [
        {
          "x": 410,
          "y": 150,
          "type": "link",
          "path": "/Applications"
        },
        {
          "x": 130,
          "y": 150,
          "type": "file"
        }
      ]
    },
    "mac": {
      "icon": "build/icons/icon.icns"
    },
    "win": {
      "icon": "build/icons/icon.ico"
    },
    "linux": {
      "icon": "build/icons"
    }
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.8",
    "@fortawesome/free-solid-svg-icons": "^5.5.0",
    "@fortawesome/vue-fontawesome": "^0.1.2",
    "axios": "^0.18.0",
    "bcryptjs": "^2.4.3",
    "bulma": "^0.7.2",
    "electron-json-storage": "^4.1.4",
    "font-awesome": "^4.7.0",
    "sqlite3": "^4.0.3",
    "vue": "^2.5.16",
    "vue-electron": "^1.0.6",
    "vue-router": "^3.0.1",
    "vue-session": "^1.0.0",
    "vuex": "^3.0.1",
    "vuex-electron": "^1.0.0"
  },
  "devDependencies": {
    "ajv": "^6.5.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "^8.2.3",
    "babel-loader": "^7.1.4",
    "babel-plugin-istanbul": "^4.1.6",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-0": "^6.24.1",
    "babel-register": "^6.26.0",
    "babili-webpack-plugin": "^0.1.2",
    "cfonts": "^2.1.2",
    "chai": "^4.1.2",
    "chalk": "^2.4.1",
    "copy-webpack-plugin": "^4.5.1",
    "cross-env": "^5.1.6",
    "css-loader": "^0.28.11",
    "del": "^3.0.0",
    "devtron": "^1.4.0",
    "electron": "^2.0.4",
    "electron-builder": "^20.19.2",
    "electron-debug": "^1.5.0",
    "electron-devtools-installer": "^2.2.4",
    "electron-packager": "^12.2.0",
    "electron-rebuild": "^1.8.2",
    "electron-winstaller": "^2.7.0",
    "eslint": "^4.19.1",
    "eslint-config-standard": "^11.0.0",
    "eslint-friendly-formatter": "^4.0.1",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-html": "^4.0.3",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-node": "^6.0.1",
    "eslint-plugin-promise": "^3.8.0",
    "eslint-plugin-standard": "^3.1.0",
    "file-loader": "^1.1.11",
    "html-webpack-plugin": "^3.2.0",
    "inject-loader": "^4.0.1",
    "karma": "^2.0.2",
    "karma-chai": "^0.1.0",
    "karma-coverage": "^1.1.2",
    "karma-electron": "^6.0.0",
    "karma-mocha": "^1.3.0",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-spec-reporter": "^0.0.32",
    "karma-webpack": "^3.0.0",
    "mini-css-extract-plugin": "0.4.0",
    "mocha": "^5.2.0",
    "multispinner": "^0.2.1",
    "node-loader": "^0.6.0",
    "node-sass": "^4.9.2",
    "postcss-loader": "^3.0.0",
    "require-dir": "^1.0.0",
    "sass-loader": "^7.0.3",
    "spectron": "^3.8.0",
    "style-loader": "^0.21.0",
    "tailwindcss": "^0.7.2",
    "url-loader": "^1.0.1",
    "vue-html-loader": "^1.2.4",
    "vue-loader": "^15.2.4",
    "vue-style-loader": "^4.1.0",
    "vue-template-compiler": "^2.5.16",
    "webpack": "^4.15.1",
    "webpack-cli": "^3.0.8",
    "webpack-dev-server": "^3.1.4",
    "webpack-hot-middleware": "^2.22.2",
    "webpack-merge": "^4.1.3"
  }
}

1 个答案:

答案 0 :(得分:3)

  1. 这取决于很多因素,包括您的硬件和项目规模。但是通常,对于中等规模的项目, 不要花费 那么长。

  2. 通常在几分钟内完成包装,例如在适当的硬件上需要3-4分钟。

一些观察结果:

  1. 根据您的依赖关系树,看起来您没有任何沉重的依赖关系。因此,假设您使用的是不错的硬件,则应该花很长时间。

  2. 另外,看起来您正在使用 webpack ,请确保已正确设置项目目录,并且其中不包含node_modules文件夹。因为这样做的话,由于 webpack 捆绑了整个node_modules目录而不是通常的src目录,因此可以解释大量的构建时间。

  3. 如果这是一个 typescript 项目,请确保在您的exclude文件中为您准备的所有(如果有)预编译库添加tsconfig.json键在您的node modules目录之外重新使用。这以前是我个人经历的,并且确实增加了您的构建时间。