gulp.task('serve', function () { var superstatic = require('superstatic/lib/server'); var app = superstatic({ config: { root: ".tmp/", clean_urls: true, debug: true, cache_control: { "**": false, "/": false }, routes: { "**": "index.html" } }, port: config.port }).listen(); console.log('Now listening on http://localhost:' + config.port); $.livereload.listen({ port: config.livereload }); // watch for changes gulp.watch([ [config.root, '.tmp/*.html'].join('/'), [config.root, '.tmp/scripts/**/*.js'].join('/'), [config.root, '.tmp/styles/**/*.css'].join('/'), [config.root, '.tmp/images/**/*'].join('/'), [config.root, '.tmp/views/partials/**/*.' + config.templateExt].join('/'), ]).on('change', function(event) { console.log('Changed', event.path); $.livereload.changed(event.path); }); gulp.watch([config.root, 'app/styles/**/*.s*ss'].join('/'), ['styles']); gulp.watch([config.root, 'app/scripts/**/*.js'].join('/'), ['scripts']); gulp.watch([config.root, 'app/views/partials/**/*.' + config.templateExt].join('/'), ['templates']); gulp.watch([config.root, 'app/*.' + config.templateExt].join('/'), ['html']); });
var server = require('superstatic/lib/server'); var Handlebars = require('handlebars'); var fs = require('fs'); var options = { gzip: process.env.gzip || true, port: process.env.port || 3000, config: { root: './dist', routes: { '**': 'index.html' } } }; var index = require('./dist/index.hbs')({ env: process.env }); fs.writeFileSync('./dist/index.html', index, 'utf-8'); server(options).listen(function() { console.info('[INFO]', 'running on port:', options.port); });