官术网_书友最值得收藏!

Setting up an NW.js project

NW.js is an open source framework for building HTML, CSS, and JavaScript applications. You can also see it as a headless browser (based on Chromium https://www.chromium.org/) that includes Node.js runtime and provides desktop environment integration API. Actually, the framework is very easy to start with. What we need is just a start page HTML file and project manifest file (package.json).

To see it in action, we will create a project folder named file-explorer at an arbitrary location. The choice of the folder location is up to you, but I personally prefer to keep web projects in /<username>/Sites on Linux/macOS and %USERPROFILE%Sites on Windows.

As we enter the directory, we create placeholder folders for JavaScript and CSS sources (js and assets/css):

We also place a start page HTML (index.html) that consists of just a few lines:

./index.html
<!DOCTYPE html>
<html>
<body>
<h1>File Explorer</h1>
</body>
</html>

As you can guess, we shall see just this text--File Explorer-- when feeding this file to a browser.

Now, we need the Node.js manifest file (package.json). Node.js, embedded in the framework, will use it to resolve dependency package names when called with a require function or from an npm script. In addition, NW.js takes from it the project configuration data.

Why not create the manifest file and populate it with dependencies using the npm tool?

主站蜘蛛池模板: 花垣县| 策勒县| 顺义区| 潼南县| 喜德县| 隆回县| 都昌县| 河南省| 海南省| 侯马市| 仲巴县| 昆明市| 德保县| 徐汇区| 噶尔县| 婺源县| 朝阳区| 竹溪县| 轮台县| 镇赉县| 桐柏县| 沈阳市| 建瓯市| 阿合奇县| 句容市| 临邑县| 甘泉县| 黄龙县| 同仁县| 长治县| 永修县| 含山县| 信丰县| 苏州市| 上高县| 福安市| 宁国市| 盐城市| 根河市| 灌阳县| 广东省|