我是npm的新手,并不真正了解依赖项与devDependencies的关系。我知道对于测试库,他们应该进入开发人员,但是对于babel和webpack这样的东西呢?它们是否也应该在dev中,因为它们仅用于将es6和JSX反编译为原始JS?我的理解是,当您部署到heroku时,它已经与必需的库进行了反编译,因此不需要将它们托管在生产环境中吗?

  "dependencies": {
    "babel-core": "^6.7.7",
    "babel-eslint": "^6.0.4",
    "babel-loader": "^6.2.4",
    "babel-plugin-react-transform": "^2.0.2",
    "babel-plugin-transform-object-rest-spread": "^6.6.5",
    "babel-plugin-transform-react-display-name": "^6.5.0",
    "babel-polyfill": "^6.7.4",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-react": "^6.5.0",
    "bootstrap": "^3.3.7",
    "css-loader": "^0.23.1",
    "es6-promise": "^3.2.1",
    "eslint": "^2.9.0",
    "eslint-plugin-babel": "^3.2.0",
    "eslint-plugin-react": "^5.0.1",
    "express": "^4.13.4",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.9.0",
    "lodash": "^4.15.0",
    "react": "^15.0.2",
    "react-addons-css-transition-group": "^15.0.2",
    "react-dom": "^15.0.2",
    "react-redux": "^4.4.5",
    "react-transform-catch-errors": "^1.0.2",
    "react-transform-hmr": "^1.0.4",
    "redbox-react": "^1.2.3",
    "redux": "^3.5.2",
    "redux-form": "^6.1.0",
    "rimraf": "^2.5.2",
    "style-loader": "^0.13.1",
    "webpack-dev-middleware": "^1.6.1",
    "webpack-hot-middleware": "^2.10.0"
  },
  "devDependencies": {
    "babel-register": "^6.9.0",
    "chai": "^3.5.0",
    "mocha": "^2.5.3",
    "sinon": "^1.17.4",
    "webpack": "^1.13.2"
  }

最佳答案

babelwebpack软件包将进入devDependencies部分,因为在将代码转换并 bundle 到bundle.js&etc文件中的 Vanilla javascript中时,将使用这些软件包。

在生产中,您将在bundle.js构建/生成的代码之外运行代码,不再需要这些依赖项。

关于javascript - 您是否将Babel和Webpack放在devDependencies或Dependencies中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40143357/

10-10 19:19