diff --git a/gulp/config.js b/gulp/config.js index 65996e30..6f75cb88 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -35,6 +35,10 @@ function viewJsDir() { return `primo-explore/custom/${view}/js`; } +function viewImgDir() { + return `primo-explore/custom/${view}/img`; +} + function mainPath() { return viewJsDir()+'/*.js'; } @@ -43,6 +47,10 @@ function mainJsPath() { return viewJsDir()+'/main.js'; } +function mainImgPath() { + return viewImgDir()+'/*.{png, ico, gif, jpg, svg}'; +} + function customCssMainPath() { return viewCssDir()+'/*.css'; } @@ -75,6 +83,10 @@ function customNpmCssPath() { return `primo-explore/custom/${view}/node_modules/primo-explore*/css/*.css`; } +function customNpmImgPath() { + return `primo-explore/custom/${view}/node_modules/primo-explore*/img/*.{png, ico, gif, jpg, svg}`; +} + var SERVERS = { @@ -93,13 +105,16 @@ let buildParams = { customModulePath: customModulePath, mainPath: mainPath, mainJsPath: mainJsPath, + mainImgPath: mainImgPath, viewJsDir: viewJsDir, viewCssDir: viewCssDir, + viewImgDir: viewImgDir, customCssPath: customCssPath, customNpmJsPath: customNpmJsPath, customNpmJsCustomPath: customNpmJsCustomPath, customNpmJsModulePath: customNpmJsModulePath, customNpmCssPath: customNpmCssPath, + customNpmImgPath: customNpmImgPath, customCssMainPath: customCssMainPath, customColorsPath: customColorsPath }; @@ -112,4 +127,3 @@ module.exports = { getBrowserify: getBrowserify, setBrowserify: setBrowserify }; - diff --git a/gulp/tasks/images.js b/gulp/tasks/images.js new file mode 100644 index 00000000..3432a8d2 --- /dev/null +++ b/gulp/tasks/images.js @@ -0,0 +1,17 @@ +'use strict'; + +const gulp = require('gulp'); +const flatten = require('gulp-flatten'); +const config = require('../config.js'); + +let buildParams = config.buildParams; + +gulp.task('watch-img', () => { + gulp.watch([buildParams.viewImgDir(), '!'+buildParams.customNpmImgPath()],['custom-img']); +}); + +gulp.task('custom-img', () => { + return gulp.src(buildParams.customNpmImgPath()) + .pipe(flatten()) + .pipe(gulp.dest(buildParams.viewImgDir())); +}); diff --git a/gulp/tasks/servers.js b/gulp/tasks/servers.js index a77137b7..d4879609 100644 --- a/gulp/tasks/servers.js +++ b/gulp/tasks/servers.js @@ -14,7 +14,7 @@ let prompt = require('prompt'); -gulp.task('setup_watchers', ['watch-js', 'watch-css'], () => { +gulp.task('setup_watchers', ['watch-js', 'watch-css', 'watch-img'], () => { gulp.watch(config.buildParams.customPath(),() => { return browserSyncManager.reloadServer(); }); @@ -22,6 +22,9 @@ gulp.task('setup_watchers', ['watch-js', 'watch-css'], () => { return gulp.src(config.buildParams.customCssPath()) .pipe(browserSyncManager.streamToServer()); }); + gulp.watch(config.buildParams.mainImgPath(),() => { + return browserSyncManager.reloadServer(); + }); }); @@ -67,7 +70,7 @@ gulp.task('connect:primo_explore', function() { let hostname = parts[0]; let port = parts[1]; - + let options = { hostname: hostname, port: port, @@ -104,4 +107,4 @@ gulp.task('connect:primo_explore', function() { }); }); -gulp.task('run', ['connect:primo_explore','setup_watchers','custom-js','custom-css']); //watch +gulp.task('run', ['connect:primo_explore','setup_watchers','custom-js','custom-css', 'custom-img']); //watch diff --git a/package.json b/package.json index 05c7a2dc..8e52c53a 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "gulp-concat": "2.6.0", "gulp-cssnano": "2.1.2", "gulp-debug": "2.1.2", + "gulp-flatten": "^0.3.1", "gulp-plumber": "1.1.0", "gulp-rename": "1.2.2", "gulp-sass": "2.3.2",