Skip to content

Commit 88ce8cf

Browse files
committed
added resolve path to grunt and gulp to guard against any relative path problems.
added watch for fonts and images folder
1 parent bf17ef5 commit 88ce8cf

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

Gruntfile.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,29 @@ module.exports = function(grunt) {
6262
copy: {
6363
main: {
6464
files: [
65-
{ expand: true, cwd: paths().source.js, src: '*.js', dest: paths().public.js},
66-
{ expand: true, cwd: paths().source.css, src: '*.css', dest: paths().public.css },
67-
{ expand: true, cwd: paths().source.images, src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: paths().public.images },
68-
{ expand: true, cwd: paths().source.fonts, src: '*', dest: paths().public.fonts},
69-
{ expand: true, cwd: paths().source.data, src: 'annotations.js', dest: paths().public.data}
65+
{ expand: true, cwd: path.resolve(paths().source.js), src: '*.js', dest: path.resolve(paths().public.js) },
66+
{ expand: true, cwd: path.resolve(paths().source.css), src: '*.css', dest: path.resolve(paths().public.css) },
67+
{ expand: true, cwd: path.resolve(paths().source.images), src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: path.resolve(paths().public.images) },
68+
{ expand: true, cwd: path.resolve(paths().source.fonts), src: '*', dest: path.resolve(paths().public.fonts) },
69+
{ expand: true, cwd: path.resolve(paths().source.data), src: 'annotations.js', dest: path.resolve(paths().public.data) }
7070
]
7171
},
7272
styleguide: {
7373
files: [
74-
{ expand: true, cwd: paths().source.styleguide, src: ['*.*', '**/*.*'], dest: paths().public.styleguide }
74+
{ expand: true, cwd: path.resolve(paths().source.styleguide), src: ['*.*', '**/*.*'], dest: path.resolve(paths().public.styleguide) }
7575
]
7676
}
7777
},
7878
watch: {
7979
all: {
8080
files: [
81-
paths().source.css + '**/*.css',
82-
paths().source.styleguide + 'css/*.css',
83-
paths().source.patterns + '**/*.mustache',
84-
paths().source.patterns + '**/*.json',
85-
paths().source.data + '*.json'
81+
path.resolve(paths().source.css + '**/*.css'),
82+
path.resolve(paths().source.styleguide + 'css/*.css'),
83+
path.resolve(paths().source.patterns + '**/*.mustache'),
84+
path.resolve(paths().source.patterns + '**/*.json'),
85+
path.resolve(paths().source.fonts + '/*'),
86+
path.resolve(paths().source.images + '/*'),
87+
path.resolve(paths().source.data + '*.json')
8688
],
8789
tasks: ['default', 'bsReload:css']
8890
}
@@ -93,7 +95,7 @@ module.exports = function(grunt) {
9395
browserSync: {
9496
dev: {
9597
options: {
96-
server: paths().public.root,
98+
server: path.resolve(paths().public.root),
9799
watchTask: true,
98100
watchOptions: {
99101
ignoreInitial: true,
@@ -103,15 +105,15 @@ module.exports = function(grunt) {
103105
{
104106
module: 'bs-html-injector',
105107
options: {
106-
files: [paths().public.root + '/index.html', paths().public.styleguide + '/styleguide.html']
108+
files: [path.resolve(paths().public.root + '/index.html'), path.resolve(paths().public.styleguide + '/styleguide.html')]
107109
}
108110
}
109111
]
110112
}
111113
}
112114
},
113115
bsReload: {
114-
css: paths().public.root + '**/*.css'
116+
css: path.resolve(paths().public.root + '**/*.css')
115117
}
116118
});
117119

gulpfile.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,51 +62,51 @@ gulp.task('banner', function(){
6262

6363
// JS copy
6464
gulp.task('cp:js', function(){
65-
return gulp.src('**/*.js', {cwd:paths().source.js})
66-
.pipe(gulp.dest(paths().public.js));
65+
return gulp.src('**/*.js', {cwd: path.resolve(paths().source.js)} )
66+
.pipe(gulp.dest(path.resolve(paths().public.js)));
6767
});
6868

6969
// Images copy
7070
gulp.task('cp:img', function(){
7171
return gulp.src(
7272
[ '**/*.gif', '**/*.png', '**/*.jpg', '**/*.jpeg' ],
73-
{cwd:paths().source.images} )
74-
.pipe(gulp.dest(paths().public.images));
73+
{cwd: path.resolve(paths().source.images)} )
74+
.pipe(gulp.dest(path.resolve(paths().public.images)));
7575
});
7676

7777
// Fonts copy
7878
gulp.task('cp:font', function(){
79-
return gulp.src('*', {cwd:paths().source.fonts})
80-
.pipe(gulp.dest(paths().public.images));
79+
return gulp.src('*', {cwd: path.resolve(paths().source.fonts)})
80+
.pipe(gulp.dest(path.resolve(paths().public.images)));
8181
});
8282

8383
// Data copy
8484
gulp.task('cp:data', function(){
85-
return gulp.src('annotations.js', {cwd:paths().source.data})
86-
.pipe(gulp.dest(paths().public.data));
85+
return gulp.src('annotations.js', {cwd: path.resolve(paths().source.data)})
86+
.pipe(gulp.dest(path.resolve(paths().public.data)));
8787
});
8888

8989
// CSS Copy
9090
gulp.task('cp:css', function(){
9191
return gulp.src(path.resolve(paths().source.css, 'style.css'))
92-
.pipe(gulp.dest(paths().public.css))
92+
.pipe(gulp.dest(path.resolve(paths().public.css)))
9393
.pipe(browserSync.stream());
9494
});
9595

9696
// Styleguide Copy
9797
gulp.task('cp:styleguide', function(){
9898
return gulp.src(
9999
[ '**/*'],
100-
{cwd:paths().source.styleguide} )
101-
.pipe(gulp.dest(paths().public.styleguide))
100+
{cwd: path.resolve(paths().source.styleguide)} )
101+
.pipe(gulp.dest(path.resolve(paths().public.styleguide)))
102102
.pipe(browserSync.stream());;
103103
});
104104

105105
//server and watch tasks
106106
gulp.task('connect', ['lab'], function(){
107107
browserSync.init({
108108
server: {
109-
baseDir: paths().public.root
109+
baseDir: path.resolve(paths().public.root)
110110
}
111111
});
112112
gulp.watch(path.resolve(paths().source.css, '**/*.css'), ['cp:css']);
@@ -118,6 +118,9 @@ gulp.task('connect', ['lab'], function(){
118118
path.resolve(paths().source.patterns, '**/*.mustache'),
119119
path.resolve(paths().source.patterns, '**/*.json'),
120120
path.resolve(paths().source.data, '*.json'),
121+
path.resolve(paths().source.fonts + '/*'),
122+
path.resolve(paths().source.images + '/*'),
123+
path.resolve(paths().source.data + '*.json'),
121124
],
122125
['lab-pipe'],
123126
function () { browserSync.reload(); }

0 commit comments

Comments
 (0)