Skip to content

Commit

Permalink
enable copying images from npm packages (#30)
Browse files Browse the repository at this point in the history
* enable copying images from npm packages

* allow .ico, .jpg and .gif images

* allow .ico, .jpg and .gif images

* allow .svg images
  • Loading branch information
thatbudakguy authored and NoamaExl committed Mar 6, 2017
1 parent 8c2f65c commit 7abe8af
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
16 changes: 15 additions & 1 deletion gulp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand All @@ -43,6 +47,10 @@ function mainJsPath() {
return viewJsDir()+'/main.js';
}

function mainImgPath() {
return viewImgDir()+'/*.{png, ico, gif, jpg, svg}';
}

function customCssMainPath() {
return viewCssDir()+'/*.css';
}
Expand Down Expand Up @@ -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 = {
Expand All @@ -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
};
Expand All @@ -112,4 +127,3 @@ module.exports = {
getBrowserify: getBrowserify,
setBrowserify: setBrowserify
};

17 changes: 17 additions & 0 deletions gulp/tasks/images.js
Original file line number Diff line number Diff line change
@@ -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()));
});
9 changes: 6 additions & 3 deletions gulp/tasks/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ 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();
});
gulp.watch(config.buildParams.customCssPath(),() => {
return gulp.src(config.buildParams.customCssPath())
.pipe(browserSyncManager.streamToServer());
});
gulp.watch(config.buildParams.mainImgPath(),() => {
return browserSyncManager.reloadServer();
});
});


Expand Down Expand Up @@ -67,7 +70,7 @@ gulp.task('connect:primo_explore', function() {
let hostname = parts[0];
let port = parts[1];


let options = {
hostname: hostname,
port: port,
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7abe8af

Please sign in to comment.