使用grunt js进行js的链接和压缩
1,http://nodejs.org/download/ 安装nodejs
2,配置环境变量,将nodejs的安装目录放置在Path环境变量中
3,在cmd中 npm install -g grunt-cli,如果已经安装的话npm uninstall -g grunt 这句话可以删除
4,grunt -version 可以查看是否安装成功
5,在要压缩的跟目录中创建package.json
6, 一个简单的package.json样例
{
"name": "umeditor",
"title": "umeditor",
"description": "umeditor",
"version": "1.2.2",
"homepage": "https://github.com/fex-team/umeditor",
"author": {
"name": "f-cube @ FEX",
"url": "http://fex.baidu.com"
},
"repository": {
"type": "git",
"url": "https://github.com/fex-team/umeditor.git"
},
"keywords": [
"umeditor",
"web editor",
"ueditor",
"javascript"
],
"bugs": {
"url": "https://github.com/fex-team/umeditor/issues"
},
"dependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-closurecompiler": "~0.9.9",
"grunt-contrib-copy": "~0.4.0",
"grunt-transcoding": "~0.1.1",
"grunt-text-replace": "~0.3.9",
"grunt-contrib-compress": "~0.7.0"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "^0.3.0",
"grunt-contrib-uglify": "^0.5.1"
}
}
7,创建 Gruntfile.js
一个简单的样例
module.exports = function(grunt) {
grunt.initConfig({
//our JSHint options
//our concat options
concat: {
options: {
},
dist: {
src: ['Src/*.js'], //Grunt mini match for your scripts to concatenate
dest: 'dest/edit.js' //where to output the script
}
},
//our uglify options
uglify: {
js: {
files: {
'dest/edit.js': ['dest/edit.js'] //save over the newly created script
}
}
}
});
//load our tasks
//grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
// default tasks to run
grunt.registerTask('default', ['concat', 'uglify']);
//grunt.registerTask('development', ['jshint']);
//grunt.registerTask('production', ['jshint', 'concat', 'uglify']);
}
7,执行npm install grunt --save-dev 可以将最新的grunt到你的目录下
8,执行grunt 命令就实现打包了
使用grunt js进行js的链接和压缩的更多相关文章
- 使用GruntJS链接与压缩多个JavaScript文件
使用GruntJS链接与压缩多个JavaScript文件 自己写了个简单的HTML5 Canvas的图表库,可以支持饼图,折线图,散点图,盒子图 柱状图,同时支持鼠标提示,绘制过程动画效果等.最终我想 ...
- 配置grunt进行css、js的检查、合并和压缩
现在会进行代码的合并和压缩已成为前端人员的必备知识,那么现在来介绍一个grunt的工具.grunt是个风靡世界的工具,它的首页是 http://www.gruntjs.net 这是个中文网站,有文档 ...
- js获取带#号链接后的参数
现在许多的主流网站都将'#'大规模用于重要URL中,我们通过正则表达式和window.location.search获取参数已经行不通了. 一.'#'号是什么 1.#代表网页中的一个位置.其后面的字符 ...
- 使用Ant和YUICompressor链接合并压缩你的JS和CSS代码
JS代码和CSS代码在上线前要压缩大家应该都是知道的了.记得之前做项目的时候,最后要交差的时候是找了个网站,将JS代码的文件一个一个地复制,粘贴,复制,粘贴. 当时就在想:TMD有没有好一点的方法,劳 ...
- Grunt:GruntFile.js
ylbtech-Grunt:GruntFile.js 1.返回顶部 1. module.exports = function (grunt) { grunt.initConfig({ useminPr ...
- 网易云音乐JS逆向解析歌曲链接
Request URL: https://music.163.com/weapi/song/enhance/player/url?csrf_token= FormData : params: BV ...
- 一统江湖的大前端(2)—— Mock.js + Node.js 如何与后端潇洒分手
<一统江湖的大前端>系列是自己的前端学习笔记,旨在介绍javascript在非网页开发领域的应用案例和发现各类好玩的js库,不定期更新.如果你对前端的理解还是写写页面绑绑事件,那你真的是有 ...
- Python-JS (JS介绍~JS的基础数据类型)
目录一.JS语言介绍: 1.JS概念 2.JS组成 二.JS的三种存在位置(引入方式): 1.行间式: 2.内联式: 3.外联式: 三.JS出现的具体位置: 四.JS语法规范 五.JS中变量的定义 E ...
- error in static/js/xxx.js from UglifyJs Unpected token: punc() [static/js/xxx.js]
出现问题 使用vue+element-ui+webpack开发项目时,Jenkins构建出现报错error in static/js/xxx.js from UglifyJs Unpected tok ...
- html+js(swiper.js)+css左右滑动切换页面效果,适配移动端
demo: 截图: 结构:1.swiper-progress.html2.css文件夹 -swiper.css -swiper.min.css 3.js文件夹 -swiper.min.js -swip ...
随机推荐
- CEF General Usage(CEF3预览)
CEF General Usage(CEF3预览) 介绍 CEF全称Chromium Embedded Framework,是一个基于Google Chromium 的开源项目.Google Chro ...
- Leetcode总结之DFS
package DFS; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; impo ...
- 奇酷手机显示Log
1.在桌面点击拨号,在拨号盘输入“*20121220#”,进入工程模式;2.看到日志输出等级,点进去 Log print enable 选 enable Java log level 选 LOGV C ...
- 【面试 IO】【第十一篇】 java IO
1.什么是比特(Bit),什么是字节(Byte),什么是字符(Char),它们长度是多少,各有什么区别 1>Bit最小的二进制单位 ,是计算机的操作部分 取值0或者1 2>Byte是计算机 ...
- jquery怎么找到元素下面的第一个子元素
<ul><li>11</li><li>22</li><li>33</li><li>44</li&g ...
- CSRF攻击 & XSS攻击
之前有几篇文章写了 SQL注入类问题: http://www.cnblogs.com/charlesblc/p/5987951.html (介绍) http://www.cnblogs.com/cha ...
- Six ways to think like a journalist!
Journalists have the ability to state a thing more clearly. What can we learn from them to help us r ...
- Jquery:怎样让子窗体的div显示在父窗体之上
<1> js或者jQuery訪问页面中的框架iframe. 注意:框架内的页面是不能跨域的! 如果有两个页面,在同样域下. 如果:父窗体 index.html ,有id 为 subif ...
- jsp中获取spring 管理的bean(通过config)
WebApplicationContext wac = (WebApplicationContext)config.getServletContext().getAttribute(WebApplic ...
- linux遍历目录源代码
<pre code_snippet_id="1622396" snippet_file_name="blog_20160324_1_744516" nam ...