Answer the question
In order to leave comments, you need to log in
How to configure borwser-syc, nsmarty and save output to html file?
Tell me how to do it?
Now set up like this
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
notify = require("gulp-notify"),
bower = require('gulp-bower' ),
browserSync = require('browser-sync').create(),
nsmarty = require('nsmarty'),
util = require('util');
var config = {
sassPath: './resources/sass',
bowerDir: './bower_components'
};
nsmarty.tpl_path = './resources/tpl';
var $arr = {
title: 'Hi, I am nsmarty template engine!',
books: [
{
title : 'JavaScript: The Definitive Guide',
author : 'David Flanagan',
price : '31.18'
},
{
title : 'Murach JavaScript and DOM Scripting',
author : 'Ray Harris'
},
{
title : 'Head First JavaScript',
author : 'Michael Morrison',
price : '29.54'
}
]
};
gulp.task('serve', ['css'], function() {
browserSync.init({
server: "./public"
});
gulp.watch(config.sassPath + '/**/*.scss', ['css']);
gulp.watch(config.bowerDir + '/bootstrap-sass-official/assets/stylesheets/**/*.scss', ['css']);
gulp.watch("./resources/scss/*.scss", ['css']);
gulp.watch("./resources/html/*.html",['html']);
});
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest(config.bowerDir))
});
gulp.task('icons', function() {
return gulp.src(config.bowerDir + '/fontawesome/fonts/**.*')
.pipe(gulp.dest('./public/fonts'));
});
gulp.task('html', function () {
gulp.src('./resources/html/*.html')
.pipe(gulp.dest('./public'))
.pipe(browserSync.stream());
});
gulp.task('css', function () {
return sass(config.sassPath + '/style.scss', {
style: 'expanded',
loadPath: [
'./resources/sass',
config.bowerDir + '/bootstrap-sass-official/assets/stylesheets',
config.bowerDir + '/fontawesome/scss'
]
}).on("error", notify.onError(function (error) {
return "Error: " + error.message;
}))
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.stream());
});
gulp.task('default', ['bower', 'icons', 'css', 'serve']);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question