简体   繁体   English

仅使用gulp或webpack构建此节点项目

[英]Build this node project using only gulp or webpack

My project has this folder structure: 我的项目有这个文件夹结构:

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 is used to copy HTML and compile TypeScript in build folder maintaining folder structure. Gulp用于复制HTML并在build文件夹维护文件夹结构中编译TypeScript。 But I didn't found how to also bundle front-end code and node dependencies in order to make these avaiable in build/client . 但我没有找到如何捆绑前端代码和节点依赖关系,以便在build/client中使这些可用。 After some suggestion and research I used Webpack to create bundle.js . 经过一些建议和研究后,我使用Webpack创建了bundle.js

Now I've the expected result but I wonder if there is a way to only Gulp or Webpack, in order to simplify the build process. 现在我已经得到了预期的结果,但我想知道是否只有Gulp或Webpack的方法,以简化构建过程。

I wonder if there is a way to only Gulp or Webpack 我想知道是否有办法只有Gulp或Webpack

These are different tools. 这些是不同的工具。

  • Gulp: Task runners. Gulp:任务选手。 Runs code segments 运行代码段
  • Webpack: Module bundler. Webpack:模块捆绑器。 Bundles code in a manner that can be used in the browser. 以可在浏览器中使用的方式捆绑代码。

If you want a bundler (which you do) gulp will not suffice . 如果你想要一个捆绑器(你这样做) gulp是不够的

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM