你的位置:首页 > 软件开发 > Java > 前端资源构建

前端资源构建

发布时间:2015-11-12 19:00:55
前端资源构建-Grunt随着前端开发的复杂度越来越高,前端页面动辄上几十个js,十几个html页面。用户打开一个页面需要加载一堆的css,js,html文件,对于有大量用户的web应用来说,既消耗服务带宽,用户加载速度也很受影响。特别是现在大量的移动端web应用涌现出来,页面加载 ...

前端资源构建

前端资源构建-Grunt

随着前端开发的复杂度越来越高,前端页面动辄上几十个js,十几个html页面。用户打开一个页面需要加载一堆的css,js,html文件,对于有大量用户的web应用来说,既消耗服务带宽,用户加载速度也很受影响。特别是现在大量的移动端web应用涌现出来,页面加载速度至关重要,所以对前端资源做压缩是必须做的工作。grunt就是nodejs平台上一个非常优秀的前端构建工具。他可以拼接、丑化、压缩前端资源,大大提升页面访问速度

下面简要介绍grunt构建环境在windows平台的搭建过程。

1. install nodejs

nodejs for windows download address

2. install npm

open nodejs cmd window

前端资源构建

 

npm install -g grunt-cli

3. 创建grunt依赖文件

package.json

 

{ "name": "www", "version": "1.0.0", "description": "", "main": "index.js", "scripts": {  "test": "echo \"Error: no test specified\" && exit 1" }, "author": "geekchow", "license": "ISC", "devDependencies": {  "grunt": "^0.4.5",  "grunt-contrib-clean": "^0.6.0",  "grunt-contrib-concat": "~0.3.0",  "grunt-contrib-copy": "^0.8.1",  "grunt-contrib-cssmin": "^0.14.0",  "grunt-contrib-jshint": "^0.11.2",  "grunt-contrib-requirejs": "^0.4.4",  "grunt-contrib-uglify": "^0.9.2",  "grunt-css": "latest",  "grunt-filerev": "latest",  "grunt-strip": "^0.2.1",  "grunt-usemin": "latest" }}

原标题:前端资源构建

关键词:前端

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。