-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
830 additions
and
214 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
var gulp = require('gulp'), | ||
less = require('gulp-less'), | ||
rjs = require('gulp-requirejs'), | ||
uglify = require('gulp-uglify'), | ||
maps = require('gulp-sourcemaps'), | ||
minifycss = require('gulp-minify-css'), | ||
sprite = require('gulp.spritesmith'), | ||
clean = require('gulp-clean'), | ||
plumber = require('gulp-plumber'), | ||
path = { | ||
dev: './www/', | ||
dest: './build/' | ||
}; | ||
|
||
//less | ||
gulp.task('less', function () { | ||
gulp | ||
.src(path.dev+'less/styles.less') | ||
.pipe(maps.init()) | ||
.pipe(plumber(function(error){ | ||
console.log(error); | ||
console.log('-------------------------- less Syntax Error! --------------------------'); | ||
})) | ||
.pipe(less()) | ||
.pipe(minifycss({compatibility: 'ie7'})) | ||
.pipe(maps.write('./')) | ||
.pipe(gulp.dest(path.dest+'css')); | ||
}); | ||
|
||
//requirejs | ||
gulp.task('r', function() { | ||
gulp | ||
.src(path.dev+'js/config.js') | ||
.pipe(gulp.dest(path.dest+'js')); | ||
|
||
gulp | ||
.src(path.dev+'js/app/ZeroClipboard.swf') | ||
.pipe(gulp.dest(path.dest+'js/app/')); | ||
|
||
rjs({ | ||
name: 'app/main', | ||
baseUrl: path.dev+'js/lib/', | ||
paths: { | ||
core: '../core', | ||
app: '../app' | ||
}, | ||
mainConfigFile:path.dev+'js/common.js', | ||
out: 'main.js', | ||
optimize:false | ||
}) | ||
//.pipe(uglify()) | ||
.pipe(maps.write('./')) | ||
.pipe(gulp.dest(path.dest+'js/app/')); | ||
|
||
}); | ||
|
||
//清理图片 | ||
gulp.task('cleanDefaultImg', function() { | ||
gulp | ||
.src([ | ||
path.dest+'img/default/*' | ||
], {read: false}) | ||
.pipe(clean({force: true})); | ||
}); | ||
gulp.task('cleanSpriteImg', function() { | ||
gulp | ||
.src([ | ||
path.dest+'img/sprite/*' | ||
], {read: false}) | ||
.pipe(clean({force: true})); | ||
}); | ||
|
||
//复制文件 | ||
gulp.task('copy', function(){ | ||
|
||
gulp | ||
.src(path.dev+'less/lib/font-awesome-ie7.min.css') | ||
.pipe(gulp.dest(path.dest+'css/')); | ||
|
||
gulp | ||
.src(path.dev+'less/fonts/*') | ||
.pipe(gulp.dest(path.dest+'css/fonts/')); | ||
|
||
gulp | ||
.src(path.dev+'js/lib/*') | ||
.pipe(gulp.dest(path.dest+'js/lib/')); | ||
|
||
gulp | ||
.src(path.dev+'img/default/*') | ||
.pipe(gulp.dest(path.dest+'img/')); | ||
|
||
}); | ||
|
||
//合并png | ||
gulp.task('spritePNG', function () { | ||
var spriteData = gulp | ||
.src(path.dev+'img/sprite/**.png') | ||
.pipe(sprite({ | ||
imgName: 'sprite.png', | ||
cssName: 'spritePNG.css', | ||
imgPath: '../img/sprite.png' | ||
})); | ||
spriteData | ||
.img | ||
.pipe(gulp.dest(path.dest+'img/')); | ||
|
||
spriteData | ||
.css | ||
.pipe(gulp.dest(path.dev+'less/')); | ||
}); | ||
|
||
//合并jpg | ||
gulp.task('spriteJPG', function () { | ||
var spriteData = gulp | ||
.src(path.dev+'sprite/*.jpg') | ||
.pipe(sprite({ | ||
imgName: 'sprite.jpg', | ||
cssName: 'spriteJPG.css', | ||
imgPath: '../img/sprite.jpg' | ||
})); | ||
spriteData | ||
.img | ||
.pipe(gulp.dest(path.dest+'img/')); | ||
|
||
spriteData | ||
.css | ||
.pipe(gulp.dest(path.dev+'less/')); | ||
}); | ||
|
||
gulp.task('sprite', function(){ | ||
gulp.run('spritePNG'); | ||
gulp.run('spriteJPG'); | ||
}); | ||
|
||
gulp.task('default', function(){ | ||
|
||
//监听js | ||
gulp.watch(path.dev+'js/**', function(){ | ||
gulp.run('r'); | ||
}); | ||
|
||
//监听less | ||
gulp.watch(path.dev+'less/**', function(){ | ||
gulp.run('less'); | ||
}); | ||
|
||
//监听不合并图片 | ||
gulp.watch(path.dev+'img/default/**', function(){ | ||
gulp.run('cleanDefaultImg'); | ||
gulp.run('copy'); | ||
}); | ||
|
||
//监听sprite png | ||
gulp.watch(path.dev+'img/sprite/**.png', function(){ | ||
gulp.run('cleanSpriteImg'); | ||
gulp.run('spritePNG'); | ||
}); | ||
|
||
//监听sprite jpg | ||
gulp.watch(path.dev+'img/sprite/**.jpg', function(){ | ||
gulp.run('spriteJPG'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,20 @@ | ||
{ | ||
"name": "ProjectName", | ||
"name": "erp", | ||
"version": "0.1.0", | ||
"scripts": { | ||
"grunt": "grunt", | ||
"gulp": "gulp", | ||
"jsdoc": "jsdoc saogaUI/www/js/core/ -d saogaUI/doc/api/ -c saogaUI/tools/docstrap/template/jsdoc.conf.json -t saogaUI/tools/docstrap/template", | ||
"build": "npm run grunt & gulp" | ||
"build": "npm run gulp" | ||
}, | ||
"devDependencies": { | ||
"grunt": "*", | ||
"grunt-contrib-less": "*", | ||
"grunt-contrib-watch": "*", | ||
"grunt-jsdoc": "*", | ||
"grunt-contrib-requirejs": "*", | ||
"grunt-contrib-jshint": "*", | ||
"grunt-contrib-copy": "*", | ||
"grunt-contrib-clean": "*", | ||
"grunt-livereload": "*", | ||
"gulp": "*", | ||
"gulp-rename": "*", | ||
"gulp-jshint": "*", | ||
"gulp-concat": "*", | ||
"gulp-uglify": "*", | ||
"gulp-sass": "*", | ||
"gulp-jsdoc": "*", | ||
"gulp": "*", | ||
"gulp-base64": "*", | ||
"gulp-clean": "*", | ||
"gulp-less": "*", | ||
"gulp-minify-css": "*", | ||
"gulp-plumber": "^1.0.1", | ||
"gulp-requirejs": "*", | ||
"requirejs": "*", | ||
"jsdoc": "*" | ||
"gulp-sourcemaps": "*", | ||
"gulp-uglify": "*", | ||
"gulp.spritesmith": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
start npm run grunt | ||
start npm run gulp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
start gulp sprite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
module.exports = function (grunt) { | ||
grunt.initConfig({ | ||
pkg : grunt.file.readJSON('config.json'), | ||
clean: { | ||
build: { | ||
src: [ '<%= pkg.dir %>/build/' ] | ||
}, | ||
}, | ||
copy: { | ||
main:{ | ||
cwd: '<%= pkg.dir %>/www', | ||
src: ['./images/**'], | ||
dest: '<%= pkg.dir %>/build', | ||
expand: true | ||
} | ||
}, | ||
less: { | ||
prod: { | ||
files: { | ||
'<%= pkg.dir %>/build/css/styles.css': '<%= pkg.dir %>/www/less/styles.less' | ||
}, | ||
options: { | ||
cleancss: true | ||
} | ||
} | ||
}, | ||
requirejs: { | ||
main: { | ||
options: { | ||
baseUrl: "www/js/lib", | ||
paths: { | ||
core: '../core', | ||
app: '../app' | ||
}, | ||
//include: 'requireLib',//如果需要把require也压进去(这样整个项目只需要一个js文件了),设置其path,并 | ||
mainConfigFile: "www/js/common.js", //用已写好的main.js文件来处理模块依赖关系 | ||
name: "app/main", // 模块的名称 | ||
out: "build/js/app/main.js" //输出的文件名 | ||
,optimize:'none',//注释掉此行即可同时把合并后的js文件压缩 | ||
} | ||
} | ||
}, | ||
livereload: { | ||
options: { | ||
base: '<%= pkg.root %>', | ||
}, | ||
files: ['**'] | ||
}, | ||
watch: { | ||
requirejs:{ | ||
files: ['<%= pkg.dir %>/www/js/*.js', '<%= pkg.dir %>/www/js/**/*.js'], | ||
tasks: ['js'] | ||
}, | ||
less: { | ||
files: ['<%= pkg.dir %>/www/less/*.less', '<%= pkg.dir %>/www/less/**/*.less'], | ||
tasks: ['requirejs'] | ||
}, | ||
copy:{ | ||
files: [ | ||
'<%= pkg.dir %>/www/images/*.*', | ||
'<%= pkg.dir %>/www/images/**/*.*', | ||
'<%= pkg.dir %>/www/js/*.*', | ||
'<%= pkg.dir %>/www/js/**/*.*' | ||
], | ||
tasks: ['copy'] | ||
}, | ||
|
||
livereload: { | ||
options: {livereload: true}, | ||
files: ['<%= pkg.root %>/**'] | ||
|
||
} | ||
} | ||
}); | ||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-less'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
grunt.loadNpmTasks('grunt-contrib-requirejs'); | ||
grunt.registerTask('default', ['watch']); | ||
//grunt.registerTask('default', ['clean', 'copy', 'less', 'requirejs']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"root":"saogaUI", | ||
"dir":"." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.