Skip to content

Commit

Permalink
add work flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
schoeu committed Feb 7, 2018
1 parent 0d8e547 commit 90dc601
Show file tree
Hide file tree
Showing 16 changed files with 10,654 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jspm_packages
node_modules
cache.json
log
.DS_Store
.DS_Store
2 changes: 1 addition & 1 deletion example/map.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"title": "MY DOCX",
"index": "/readme.md",
"logPath": "./log",
"theme": "default",
"theme": "antd",
"supportInfo": "mailto:[email protected]",
"extUrls": {
"label": "友情链接",
Expand Down
75 changes: 75 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* gulp配置文件
* */
var path = require('path');

var gulp = require('gulp');
var uglify = require('gulp-uglify');
var minify = require('gulp-minify-css');
var livereload = require('gulp-livereload')
var rename = require("gulp-rename");
var clean = require('gulp-clean');
var concat = require('gulp-concat');

var options = process.argv.slice(2) || [];
var themes = 'default';
if (options.length > 1 && options[0] == '--theme') {
themes = options[1];
}
console.log('~~~~~',themes)

var staticPath = path.join('./themes/', themes, './static');
var distPath = path.join(staticPath, './dist');

var srcOpts = {
buffer: true
};

var jsDir = 'javascripts';
var styDir = 'stylesheets';

// 默认任务
gulp.task('default', ['mini']);

// 压缩js/css任务
gulp.task('mini', ['clean'],function () {
// 压缩js
gulp.src([
staticPath + '/' + jsDir + '/jq.js',
staticPath + '/' + jsDir + '/bootstrap.js',
staticPath + '/' + jsDir + '/jq.pjax.js',
staticPath + '/' + jsDir + '/metisMenu.js',
staticPath + '/' + jsDir + '/fullImage.js',
staticPath + '/' + jsDir + '/doc.js'
], srcOpts)
.pipe(uglify())
.pipe(concat('docx.js'))
.pipe(gulp.dest(distPath + '/' + jsDir + '/'))
.pipe(livereload());

// 压缩css
gulp.src([staticPath + '/' + styDir + '/*.css', '!' + staticPath + '/' + styDir + '/*.min.css'])
.pipe(minify())
.pipe(concat('docx.css'))
.pipe(gulp.dest(distPath + '/' + styDir + '/'))
.pipe(livereload());
});

gulp.task('clean', function () {
return gulp.src([staticPath + '/dist/'], {read: false})
.pipe(clean());
});

gulp.task('watch', function () {
livereload.listen();

// 监听目录下的文件,若文件发生变化,则调用mini任务。
gulp.watch(
[
staticPath + '/' + jsDir + '/*.js',
staticPath + '/' + styDir + '/*.css',
path.join(__dirname, './views/*')
]
, ['mini']
);
});
Loading

0 comments on commit 90dc601

Please sign in to comment.