Skip to content

Commit

Permalink
Fixed bug with gulp-inject and dirnames
Browse files Browse the repository at this point in the history
  • Loading branch information
garciparedes committed Jul 14, 2016
1 parent 3c8ae16 commit ee2e8e2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
5 changes: 3 additions & 2 deletions gulp-examples/first-gulp/PUBLIC/css/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
body {
font: 100% Helvetica, sans-serif;
background-color: #000000; }
body h1 {
color: #333; }
body h1, body h2, body h3, body h4, body h5, body h6 {
text-align: center;
color: #ffffff; }
9 changes: 7 additions & 2 deletions gulp-examples/first-gulp/PUBLIC/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
<title>This is title</title>

<!-- inject:css -->
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="css/style.css">
<!-- endinject -->
</header>
<body>
<h1>Text in H1</h1>
<h2>Text in H2</h2>
<h3>Text in H3</h3>
<h4>Text in H4</h4>
<h5>Text in H5</h5>
<h6>Text in H6</h6>

<!-- inject:js -->
<script src="/js/app.js"></script>
<script src="js/app.js"></script>
<!-- endinject -->
</body>
</html>
23 changes: 19 additions & 4 deletions gulp-examples/first-gulp/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,41 @@ const PUBLIC_JS_DIRNAME = PUBLIC_DIRNAME + '/js';
const SASS_DIRNAME = './sass';



// Start
//##############################################################################

gulp.task('default', ['sass', 'inject']);


// Sass
//##############################################################################

gulp.task('sass', function () {
return gulp.src(SASS_DIRNAME + '/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(PUBLIC_CSS_DIRNAME));
});


gulp.task('sass:watch', function () {
gulp.watch(SASS_DIRNAME + '/**/*.scss', ['sass']);
});


// css & js inyector
//##############################################################################

gulp.task('inject',['sass'], function () {
var target = gulp.src(PUBLIC_DIRNAME + '/index.html');
// It's not necessary to read the files (will speed up things), we're only after their paths:
var sources = gulp.src([PUBLIC_JS_DIRNAME + '/**/*.js', PUBLIC_CSS_DIRNAME + '/**/*.css'], {read: false});

return target.pipe(inject(sources))
var sources = gulp.src([
PUBLIC_JS_DIRNAME + '/**/*.js',
PUBLIC_CSS_DIRNAME + '/**/*.css'
], {read: false});

return target.pipe(inject(sources, {relative: true}))
.pipe(gulp.dest(PUBLIC_DIRNAME));
});


//##############################################################################
5 changes: 3 additions & 2 deletions gulp-examples/first-gulp/sass/style.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
$primary-color: #ffffff;
$black: #000000;


body {
font: 100% $font-stack;
background-color: $black;

h1 {
h1, h2, h3, h4, h5, h6 {
text-align: center;
color: $primary-color;

}
Expand Down

0 comments on commit ee2e8e2

Please sign in to comment.