1

I've been looking at nodejs and how to create and require modules. Makes sense and works great.

I am interested though in using a concat function gulp-concat at the moment to concat all the js files into one js file.

This got me thinking that it is not possible when setting up a modular environment as when using the require function requires the modules to be in other files.

Is there a standard way of dealing with this? Are the files supposed to be in separate files?

4

1 回答 1

2

Node.js 通常在服务器端或作为桌面进程运行。与在浏览器中运行的 JavaScript 不同,其中连接文件具有优势,Node.js 不需要这样做。与 Java 或 C# 应用程序类似,将类/模块分离到文件中可以更轻松地管理代码并且更易于维护。

gulp-concat很可能被开发人员用作连接任意 JavaScript 文件的工具,这些文件最终会出现在浏览器中。

于 2015-03-22T22:55:20.077 回答