gpt4 book ai didi

node.js - 仅使用 gulp 或 webpack 构建此 Node 项目

转载 作者:太空宇宙 更新时间:2023-11-04 02:05:41 24 4
gpt4 key购买 nike

我的项目具有以下文件夹结构:

node
| .gitignore
| gulpfile.js
| package.json
| tsconfig.json
| webpack.config.js
|
+---build
| | debug.js
| | main.js
| |
| +---client
| | +---scripts
| | | bundle.js
| | |
| | \---views
| | index.html
| |
| |
| \---server
| | constants.js
| | server.js
| |
| \---router
| | constants.js
| | router.js
| |
| \---routes
| base.js
| index.js
|
+---gulp
| | constants.js
| |
| \---tasks
| default.js
| html.js
| typescript.js
|
\---src
| main.ts
|
+---client
| +---app
| | | app.tsx
| | |
| | \---components
| | hello.tsx
| |
| \---views
| index.html
|
\---server
| constants.ts
| server.ts
|
\---router
| constants.ts
| router.ts
|
\---routes
base.ts
index.ts

Gulp 用于在 build 文件夹中复制 HTML 并编译 TypeScript,维护文件夹结构。但我没有找到如何捆绑前端代码和 Node 依赖项以使它们在 build/client 中可用。经过一些建议和研究后,我使用 Webpack 创建 bundle.js

现在我已经得到了预期的结果,但我想知道是否有办法只使用 Gulp 或 Webpack,以简化构建过程。

最佳答案

I wonder if there is a way to only Gulp or Webpack

这些是不同的工具。

  • Gulp:任务运行程序。运行代码段
  • Webpack:模块 bundler 。以可在浏览器中使用的方式捆绑代码。

如果您想要一个 bundler (您确实需要)gulp 是不够的

关于node.js - 仅使用 gulp 或 webpack 构建此 Node 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44424484/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com