简体   繁体   English

在构建脚本中使用 Babel 时,如何为生产部署设置依赖项?

[英]How do you setup dependencies for production deploy when Babel is used in build script?

My understanding is that Babel is used for compiling codes, so it makes sense to be placed at devDependencies.我的理解是 Babel 是用来编译代码的,所以放在 devDependencies 是有意义的。

But if I include Babel command in my build script and I would like to npm install --only=prod before npm run build at deploy stage (or Dockerfile).但是,如果我在构建脚本中包含 Babel 命令,并且我想在 npm 在部署阶段(或 Dockerfile) npm run build之前npm install --only=prod npm。

Should I move Babel and related packages like plugins, preset into dependencies?我应该将 Babel 和相关的包(如插件、预设)移动到依赖项中吗?

Just found out a reasonable solution .刚刚找到一个合理的解决方案

If the project needs to be built by babel, then如果项目需要 babel 构建,那么

our project is no longer considered the "front end app", but instead "the project that builds the front end app.我们的项目不再被认为是“前端应用程序”,而是“构建前端应用程序的项目。

Therefore installing babel related dependencies in production is fine.因此在生产环境中安装 babel 相关的依赖是没问题的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你把Babel和Webpack放在devDependencies或Dependencies中吗? - Do you put Babel and Webpack in devDependencies or Dependencies? 您如何将其“翻译”成<script setup>? - How do you "translate" this into <script setup>? 如何从 Vue 3 中的脚本设置中导出默认值? - How do you export default from inside script setup in Vue 3? 使用babel和es6如何部署app到Heroku? - How to deploy app to Heroku if you use Babel and ES6? 即使在脚本上使用 text/babel 时,意外的标记 '&lt;' - Unexpected token '<' even when text/babel is used on script 将Google Firebase应用程序部署与Aurelia结合使用,如何仅设置和部署打包资产? - Using the Google Firebase app deployment with Aurelia how do you setup and deploy just the packed assets? 您何时在生产中使用phi系数? - When do you use phi coefficient in production? 如何构建/部署角度2项目到生产? - How can I build/deploy an angular 2 project to production? 当我使用ng build进行部署时,如何解决angular项目中vendor.js中的错误语法 - How to resolve error syntax in vendor.js in angular project when i used ng build for deploy Babel 和 next.js - 如何在项目中构建、babel 和附加我自己的脚本 - Babel and next.js - how build, babel and attach my own script in project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM