|
@@ -7,7 +7,6 @@ let gulpLoadPlugins = require('gulp-load-plugins');
|
|
|
let del = require('del');
|
|
|
let uglify = require('gulp-uglify-es').default;
|
|
|
let config = require("./config/gulpConfig.js");
|
|
|
-let runSequence = require('run-sequence');
|
|
|
|
|
|
const $ = gulpLoadPlugins();
|
|
|
let common_jspaths=config.common_jspaths;
|
|
@@ -18,131 +17,178 @@ let login_jspaths=config.login_jspaths;
|
|
|
let main_jspaths=config.main_jspaths;
|
|
|
let main_csspaths=config.main_css;
|
|
|
let version=config.version;
|
|
|
+let cssDest='web/dest/css';
|
|
|
+let scriptsDest='web/dest/scripts';
|
|
|
+
|
|
|
+let commonOptions={
|
|
|
+ jspaths:common_jspaths,
|
|
|
+ csspaths:common_css,
|
|
|
+ concatName:'common.all.min'
|
|
|
+};
|
|
|
+
|
|
|
+let headerOptions={
|
|
|
+ version:version,
|
|
|
+ scriptsDest:'web/dest/scripts',
|
|
|
+ concatName:'header.all.min',
|
|
|
+ srcHtml:'web/src/html/common/header.html',
|
|
|
+ htmlDest:'web/common/html',
|
|
|
+ htmlName:'header.html',
|
|
|
+ injectList:['web/dest/scripts/common.all.min.'+version+'.js']
|
|
|
+};
|
|
|
+
|
|
|
+let loginOptions={
|
|
|
+ version:version,
|
|
|
+ scriptsDest:'web/dest/scripts',
|
|
|
+ jspaths:login_jspaths,
|
|
|
+ concatName:'login.all.min',
|
|
|
+ srcHtml:'web/src/html/login/login.html',
|
|
|
+ htmlDest:'web/users/html',
|
|
|
+ htmlName:'login.html',
|
|
|
+ injectList:[ 'web/dest/scripts/common.all.min.'+version+'.js',
|
|
|
+ 'web/dest/scripts/login.all.min.'+version+'.js',
|
|
|
+ 'web/dest/css/common.all.min.'+version+'.css']
|
|
|
+}
|
|
|
|
|
|
-let taskObject={};
|
|
|
-function task_init(options) {
|
|
|
- taskObject=options;
|
|
|
- taskObject.version=version;
|
|
|
- taskObject.scriptsDest='web/dest/scripts';
|
|
|
+let pmOptions={
|
|
|
+ version:version,
|
|
|
+ scriptsDest:'web/dest/scripts',
|
|
|
+ jspaths:pm_jspaths,
|
|
|
+ csspaths:pm_csspaths,
|
|
|
+ concatName:'pm.all.min',
|
|
|
+ srcHtml:'web/src/html/pm/!*.html',
|
|
|
+ htmlDest:'web/building_saas/pm/html',
|
|
|
+ htmlName:'project-management.html',
|
|
|
+ injectList:['web/dest/scripts/pm.all.min.'+version+'.js',
|
|
|
+ 'web/dest/css/common.all.min.'+version+'.css',
|
|
|
+ 'web/dest/css/pm.all.min.'+version+'.css']
|
|
|
+};
|
|
|
+
|
|
|
+let mainOptions={
|
|
|
+ version:version,
|
|
|
+ scriptsDest:'web/dest/scripts',
|
|
|
+ jspaths:main_jspaths,
|
|
|
+ csspaths:main_csspaths,
|
|
|
+ concatName:'main.all.min',
|
|
|
+ srcHtml:'web/src/html/main/main.html',
|
|
|
+ htmlDest:'web/building_saas/main/html',
|
|
|
+ htmlName:'main.html',
|
|
|
+ injectList:['web/dest/scripts/main.all.min.'+version+'.js',
|
|
|
+ 'web/dest/css/common.all.min.'+version+'.css',
|
|
|
+ 'web/dest/css/main.all.min.'+version+'.css']
|
|
|
}
|
|
|
|
|
|
-gulp.task('minify', function (){
|
|
|
- if(taskObject.jspaths){
|
|
|
- return gulp.src(taskObject.jspaths)
|
|
|
+function minify(options) {
|
|
|
+ if(options.jspaths){
|
|
|
+ return gulp.src(options.jspaths)
|
|
|
+ .pipe($.plumber())
|
|
|
+ .pipe(uglify())
|
|
|
+ .pipe($.concat(options.concatName+"."+version+".js"))
|
|
|
+ .pipe(gulp.dest(scriptsDest));
|
|
|
+ }
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+function css(options) {
|
|
|
+ if(options.csspaths){
|
|
|
+ return gulp.src(options.csspaths)
|
|
|
.pipe($.plumber())
|
|
|
- // .pipe(uglify())
|
|
|
- .pipe($.concat(taskObject.concatName+"."+version+".js"))
|
|
|
- .pipe(gulp.dest(taskObject.scriptsDest));
|
|
|
+ .pipe($.cssnano())
|
|
|
+ .pipe($.concat(options.concatName+"."+version+".css"))
|
|
|
+ .pipe(gulp.dest(cssDest));
|
|
|
}
|
|
|
- return;
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+function inject(options) {
|
|
|
+ var target = gulp.src(options.htmlDest+'/'+options.htmlName);
|
|
|
+ var sources = gulp.src(options.injectList, {read: false});
|
|
|
+
|
|
|
+ return target.pipe($.plumber())
|
|
|
+ .pipe($.inject(sources))
|
|
|
+ .pipe(gulp.dest(options.htmlDest));
|
|
|
+}
|
|
|
+
|
|
|
+function htmlmin(options) {
|
|
|
+ return gulp.src(options.htmlDest+'/*.html')
|
|
|
+ // .pipe($.htmlmin({collapseWhitespace: true}))
|
|
|
+ .pipe(gulp.dest(options.htmlDest));
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+gulp.task('minify', function (){
|
|
|
+ return minify(commonOptions);
|
|
|
});
|
|
|
|
|
|
+gulp.task('css',function () {
|
|
|
+ return css(commonOptions);
|
|
|
+})
|
|
|
+
|
|
|
+gulp.task('common', ['minify','css']);
|
|
|
|
|
|
-gulp.task('copy',function () {
|
|
|
- return gulp.src(taskObject.srcHtml)
|
|
|
- .pipe($.plumber())
|
|
|
- .pipe(gulp.dest(taskObject.htmlDest));
|
|
|
+gulp.task('login_minify',['common'], function (){
|
|
|
+ return minify(loginOptions);
|
|
|
+});
|
|
|
+
|
|
|
+gulp.task('login_css',function () {
|
|
|
+ return css(loginOptions);
|
|
|
})
|
|
|
|
|
|
-gulp.task('inject',['minify','css'], function () {
|
|
|
- var target = gulp.src(taskObject.htmlDest+'/'+taskObject.htmlName);
|
|
|
- var sources = gulp.src(taskObject.injectList, {read: false});
|
|
|
+gulp.task('login_inject',['login_minify','login_css'],function () {
|
|
|
+ return inject(loginOptions);
|
|
|
+})
|
|
|
|
|
|
- return target.pipe($.plumber())
|
|
|
- .pipe($.inject(sources))
|
|
|
- .pipe(gulp.dest(taskObject.htmlDest));
|
|
|
+gulp.task('login',['login_inject'], function (){
|
|
|
+ return htmlmin(loginOptions);
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+gulp.task('header_minify',['common'], function (){
|
|
|
+ return minify(headerOptions);
|
|
|
});
|
|
|
|
|
|
-gulp.task('htmlmin',function () {
|
|
|
- return gulp.src(taskObject.htmlDest+'/*.html')
|
|
|
- // .pipe($.htmlmin({collapseWhitespace: true}))
|
|
|
- .pipe(gulp.dest(taskObject.htmlDest));
|
|
|
+gulp.task('header_css',function () {
|
|
|
+ return css(headerOptions);
|
|
|
})
|
|
|
|
|
|
-gulp.task('css',function () {
|
|
|
- if(taskObject.pm_csspaths){
|
|
|
- return gulp.src(taskObject.pm_csspaths)
|
|
|
- .pipe($.plumber())
|
|
|
- .pipe($.cssnano())
|
|
|
- .pipe($.concat(taskObject.concatName+"."+version+".css"))
|
|
|
- .pipe(gulp.dest(taskObject.cssDest));
|
|
|
- }
|
|
|
- return;
|
|
|
+gulp.task('header_inject',['header_minify','header_css'],function () {
|
|
|
+ return inject(headerOptions);
|
|
|
})
|
|
|
|
|
|
-gulp.task('common', function (){
|
|
|
- let options = {
|
|
|
- jspaths:common_jspaths,
|
|
|
- pm_csspaths:common_css,
|
|
|
- concatName:'common.all.min',
|
|
|
- cssDest:'web/dest/css'
|
|
|
- }
|
|
|
- task_init(options);
|
|
|
- runSequence('minify','css');
|
|
|
+gulp.task('header',['header_inject'], function (){
|
|
|
+ return htmlmin(headerOptions);
|
|
|
});
|
|
|
|
|
|
-gulp.task('header', function (){
|
|
|
- let options = {
|
|
|
- concatName:'header.all.min',
|
|
|
- srcHtml:'web/src/html/common/header.html',
|
|
|
- htmlDest:'web/common/html',
|
|
|
- htmlName:'header.html',
|
|
|
- injectList:['web/dest/scripts/common.all.min.'+version+'.js']
|
|
|
- };
|
|
|
- task_init(options);
|
|
|
- runSequence('inject','htmlmin');
|
|
|
+gulp.task('pm_minify',['common'], function (){
|
|
|
+ return minify(pmOptions);
|
|
|
});
|
|
|
|
|
|
+gulp.task('pm_css',function () {
|
|
|
+ return css(pmOptions);
|
|
|
+})
|
|
|
|
|
|
-gulp.task('login', function (){
|
|
|
- let options = {
|
|
|
- jspaths:login_jspaths,
|
|
|
- concatName:'login.all.min',
|
|
|
- srcHtml:'web/src/html/login/login.html',
|
|
|
- htmlDest:'web/users/html',
|
|
|
- htmlName:'login.html',
|
|
|
- injectList:[ 'web/dest/scripts/common.all.min.'+version+'.js',
|
|
|
- 'web/dest/scripts/login.all.min.'+version+'.js',
|
|
|
- 'web/dest/css/common.all.min.'+version+'.css']
|
|
|
- }
|
|
|
- task_init(options);
|
|
|
- runSequence('inject','htmlmin');
|
|
|
+gulp.task('pm_inject',['pm_minify','pm_css'],function () {
|
|
|
+ return inject(pmOptions);
|
|
|
+})
|
|
|
+
|
|
|
+gulp.task('pm',['pm_inject'], function (){
|
|
|
+ return htmlmin(pmOptions);
|
|
|
});
|
|
|
|
|
|
-gulp.task('pm', function (){
|
|
|
- let options = {
|
|
|
- jspaths:pm_jspaths,
|
|
|
- pm_csspaths:pm_csspaths,
|
|
|
- concatName:'pm.all.min',
|
|
|
- cssDest:'web/dest/css',
|
|
|
- srcHtml:'web/src/html/pm/*.html',
|
|
|
- htmlDest:'web/building_saas/pm/html',
|
|
|
- htmlName:'project-management.html',
|
|
|
- injectList:['web/dest/scripts/pm.all.min.'+version+'.js',
|
|
|
- 'web/dest/css/common.all.min.'+version+'.css',
|
|
|
- 'web/dest/css/pm.all.min.'+version+'.css']
|
|
|
- }
|
|
|
- task_init(options);
|
|
|
- runSequence('inject','htmlmin');
|
|
|
+gulp.task('main_minify',['common'], function (){
|
|
|
+ return minify(mainOptions);
|
|
|
});
|
|
|
|
|
|
-gulp.task('main',function () {
|
|
|
- let options ={
|
|
|
- jspaths:main_jspaths,
|
|
|
- pm_csspaths:main_csspaths,
|
|
|
- concatName:'main.all.min',
|
|
|
- cssDest:'web/dest/css',
|
|
|
- srcHtml:'web/src/html/main/main.html',
|
|
|
- htmlDest:'web/building_saas/main/html',
|
|
|
- htmlName:'main.html',
|
|
|
- injectList:['web/dest/scripts/main.all.min.'+version+'.js',
|
|
|
- 'web/dest/css/common.all.min.'+version+'.css',
|
|
|
- 'web/dest/css/main.all.min.'+version+'.css']
|
|
|
- }
|
|
|
- task_init(options);
|
|
|
- runSequence('inject','htmlmin');
|
|
|
+gulp.task('main_css',function () {
|
|
|
+ return css(mainOptions);
|
|
|
})
|
|
|
|
|
|
-gulp.task('build',['common'],function () {
|
|
|
- runSequence('header',['login','pm','main']);
|
|
|
-});
|
|
|
+gulp.task('main_inject',['main_minify','main_css'],function () {
|
|
|
+ return inject(mainOptions);
|
|
|
+})
|
|
|
+
|
|
|
+gulp.task('main',['main_inject'], function (){
|
|
|
+ return htmlmin(mainOptions);
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+gulp.task('build',['header','login','pm','main']);
|