Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We should have a way of generating non-moonboots examples, either with grunt/gulp/make or something #43

Open
latentflip opened this issue Sep 1, 2014 · 8 comments

Comments

@latentflip
Copy link
Contributor

See https://twitter.com/robhawkes/status/506380436919300096 for context.

@garrettn
Copy link

garrettn commented Sep 2, 2014

👍

Mainly, it would be helpful if the scaffolding made it easier to go from local development to deployment on a static server. I've been trying to do that with Grunt/Gulp but with no success so far.

@brianberlin
Copy link

I'm currently using grunt, with a heroku buildpack that allows for the production versions of javascript and css to be compiled on heroku. I think the reason I ended up not using moonboots was that I wanted to use sass which requires ruby gems, especially if you want to use any other sass plugins like compass.

@lukekarrys
Copy link
Contributor

@garrettn Curious if you've tried https://www.npmjs.org/package/grunt-moonboots? I've never used it but the description says it wraps moonboots-static.

@garrettn
Copy link

garrettn commented Sep 3, 2014

@lukekarrys Thanks! I hadn't seen that one. It's hard to tell from the documentation whether it provides any real advantage over using Moonboots directly, but it might be worth a look.

@fyockm
Copy link
Member

fyockm commented Oct 31, 2014

Yes, I've also been using gulp tasks instead of moonboots because of sass. I chose gulp over grunt because I feel that it's streaming nature works better for most front-end type tasks (uglify, minify, etc).

In my experience, support of multiple configurations can get a little hairy. But you've already gone down this path to some degree with express vs hapi.

@prust
Copy link

prust commented Oct 31, 2014

+1. Support, examples, etc, for a static server is even more important than for express, IMO. I would think we can & should make it agnostic to the build technology (grunt, gulp, make, etc). The simpler the better. I've been developing a tutorial for internal use that just uses browserify and/or watchify, and included one-liners for them as npm scripts...

@iamricard
Copy link

I'm looking into using AmpesandJS for my next project and I'm trying to make the current hapi.js setup on with gulp.js and handlebars templates, if successful is this something that would interest you?

@fyockm
Copy link
Member

fyockm commented Nov 1, 2014

@rcsole Here's my sample gulpfile.js to help get you rolling with gulp and handlebars. I know it still needs some additions to replace moonboots, but this has been working in place of tempatizer. Switching out jade for handlebars was one of the first necessary steps for me to use ampersand.

Hope this helps as a base. Let me know if you have any questions. I some other tasks set up for linting, sass, etc if you are interested.

var gulp = require('gulp'),
    wrap = require('gulp-wrap'),
    concat = require('gulp-concat'),
    declare = require('gulp-declare'),
    handlebars = require('gulp-handlebars'),
    nodemon = require('gulp-nodemon');

var paths = {
    templates: 'templates/**/*.hbs'
};

gulp.task('templates', function() {
    // Load templates from the templates/ folder relative to where gulp was executed
    gulp.src(paths.templates)
    // Compile each Handlebars template source file to a template function
    .pipe(handlebars())
    // Wrap each template function in a call to Handlebars.template
    .pipe(wrap('Handlebars.template(<%= contents %>)'))
    // Declare template functions as properties and sub-properties of exports
    .pipe(declare({
        root: 'exports',
        noRedeclare: true, // Avoid duplicate declarations
        processName: function(filePath) {
            // Drop the templates/ folder from the namespace path by removing it from the filePath
            return declare.processNameByPath(filePath.replace('templates/', ''));
        }
    }))
    // Concatenate down to a single file
    .pipe(concat('templates.js'))
    // Add the Handlebars module in the final output
    .pipe(wrap('var Handlebars = require("handlebars");\n <%= contents %>'))
    // Write the output into the templates folder
    .pipe(gulp.dest('client/'));
});

// Rerun the task when a file changes
gulp.task('watch', function() {
    gulp.watch(paths.templates, ['templates']);
});

gulp.task('serve', function() {
    nodemon({
        script: 'server.js',
        ext: 'js',
        ignore: ['gulpfile.js', 'templates.js']
    });
});

gulp.task('default', ['watch', 'templates', 'serve']);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants