[Whole Web] [Node.js] [Browserify] [Grunt] Automation task with grunt-browserify & grunt-contrib-watch
What we want is when the server side Node.js files have been changed, we want to use browserify to bundle all file and output just one file and later to show the console result in the browser.
For this, frist we need auto-watch: grunt-contrib-watch:
npm install grunt-contrib-watch --save-dev
Then we also install grunt-browserify:
npm install grunt-browserify --save-dev
Create 'GruntFile.js' and put in:
module.exports = function(grunt) {
grunt.initConfig({
browserify: {
'server-build/app.js': ['server/**/*.js']
},
watch: {
files: ["server/**/*.js"],
tasks: ['browserify']
}
});
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-watch');
}
What it says is that:
1. Watch all the files under server dir, including nested dir and theirs files.
2. Once those files have been modified, run browserify task.
3. The browserify task says that: bundle all the files in server dir and output to server-build dir's app.js file.
Then you can run:
grunt watch
Test file:
server/app.js:
var test = require('./test');
console.log(test());
server/test.js:
module.exports = function(){
return "Hello World";
}
More:
http://codeofrob.com/entries/grunt+browserify+npm+application=success.html
https://github.com/jmreidy/grunt-browserify
[Whole Web] [Node.js] [Browserify] [Grunt] Automation task with grunt-browserify & grunt-contrib-watch的更多相关文章
- 【win7下安装node.js错误:roling back action】与【"grunt" 不是内部或外部命令】 解决方法
[win7下安装node.js错误:roling back action] 解决方法: Node.js 服务器端的JavaScript Node.js 是一个基于Chrome JavaScript 运 ...
- [Whole Web] [Node.js] Using npm run to launch local scripts
npm run allows you to configure scripts inside of your package.json file which can access locally in ...
- [Whole Web, Node.js PM2] Loggin with PM2
Add config for app's log and error log for PM2. { "apps": [{ "name": "App1& ...
- [Whole Web, Node.js, PM2] Configuring PM2 for Node applications
In this lesson, you will learn how to configure node apps using pm2 and a json config file. Let's sa ...
- [Whole Web] [Node.js, PM2] Controlling runaway apps using pm2
shows how to enable features in your pm2 config file that allow you to prevent runaway apps from bri ...
- [Whole Web, Node.js, PM2] Restarting your node.js app on code change using pm2
Aadd watch to the config.json file: { "apps": [{ "name": "App1", " ...
- 进击Node.js基础(一)
一.前言 1:Node.js本质上是用chrome浏览器 v8引擎 使用c++编写的JS运行环境 2:相比于JS没有浏览器安全级的限制,额外提供了一些系统级的API:文件读写,进程管理,网络通信等. ...
- Node.js开发Web后台服务
一.简介 Node.js 是一个基于Google Chrome V8 引擎的 JavaScript 运行环境.Node.js 使用了一个事件驱动.非阻塞式 I/O 的模型,使其轻量又高效.Node.j ...
- 认识Web前端、Web后端、桌面app和移动app新开发模式 - 基于Node.js环境和VS Code工具
认识Web.桌面和移动app新开发模式 - 基于Node.js环境和VS Code工具 一.开发环境的搭建(基于win10) 1.安装node.js和npm 到node.js官网下载安装包(包含npm ...
随机推荐
- Java web 项目 tomcat部署方式.
本地做Java Web项目的时候常常会用到tomcat部署测试的问题, 这里介绍项目的部署方法: 1,配置文件的形式: 例如: 你的项目目录为:f:\workspaces\MyProject,此时使用 ...
- OA,ERP等源码一部分演示
更多源码http://www.pssdss.com QQ:11851298 功能强大的JAVA开发的ERP源码http://cx050027.pssdss.com:8080/ 用户名pssdss ...
- jquery页面无刷新切换皮肤并保存
效果体验:http://runjs.cn/detail/hijgcghe <!DOCTYPE html> <html> <head> <meta http-e ...
- (转)Make命令简介与使用
转载自阮一峰的博客: http://www.ruanyifeng.com/blog/2015/02/make.html 代码变成可执行文件,叫做编译(compile):先编译这个,还是先编译那个(即编 ...
- -Xms 和 -Xmx 不能设置的太大
之前我一直有一个疑问,就是-Xms 和 -Xmx不是设置的越大越好吗?现在才明白怎么回事. 通过在命令行中执行 java 或者启动某种基于 Java 的中间件来运行 Java 应用程序时,Java 运 ...
- 问题:如何在固定大小的DIV层插入N多个图片
这是贴友问的一个问题,具体需求是: 如何在固定大小的DIV层插入N多个图片,使其一行排列,超出层宽时出现滑动条? 原以为利用overflow属性可以实现,但是测试失败.后来利用div层叠实现了效果. ...
- 6.2 CUDA streams
stream是什么 nivdia给出的解释是:A sequence of operations that execute in issue-order on the GPU. 可以理解成在GPU上执 ...
- delphi 删除目录和创建目录,临时文件夹
获取用户当前的Windows临时文件夹function GetWinTempPath: string;varTempDir: array[0..255] of char;beginGetTempPat ...
- hdoj 1234 开门人和关门人
开门人和关门人 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) #include ...
- nyoj 49 开心的小明
开心的小明 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 小明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间.更让他高兴的是,妈妈昨天 ...