Skip to content

Instantly share code, notes, and snippets.

@itsthatguy
Last active August 29, 2015 14:21
Show Gist options
  • Save itsthatguy/38ba8ff6cc3097a6aa80 to your computer and use it in GitHub Desktop.
Save itsthatguy/38ba8ff6cc3097a6aa80 to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
// Grab all the gulp plugins automagically for us to use below
var $ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'del', 'main-bower-files']
});
// Swab the deck!
gulp.task('clean', function() {
return $.del.sync('dist/**/*');
});
// We use this for packaging our JS right now
gulp.task('webpack', function() {
var webpackOptions = require('./webpack.config.js');
return gulp.src('src/index.js')
.pipe($.webpack(webpackOptions))
.pipe(gulp.dest('dist/'));
});
// Moves static files to dist folder
gulp.task('assets', function() {
return gulp.src('src/**/*.{png,jpg,ttf,html}')
.pipe(gulp.dest('dist/'));
});
// Compile jade, and inject <script> tags for
// all of the bower dependencies
gulp.task('jade', function() {
var bowerSrc = gulp.src($.mainBowerFiles(), {read: false});
return gulp.src('src/**/*.jade')
.pipe($.inject(bowerSrc, {
name: 'bower',
addPrefix: '..',
addRootSlash: false
}))
.pipe($.jade({pretty: true}))
.pipe(gulp.dest('dist/'))
});
// Nothing special
gulp.task('sass', function() {
return gulp.src('src/**/*.scss')
.pipe($.sass())
.pipe(gulp.dest('dist/'))
});
// Watching the things
gulp.task('watch', ['default'], function() {
function watch(src, task) {
$.watch(src, function() {
gulp.start(task);
});
}
watch('src/**/*.{png,jpg,html}', 'assets');
watch('src/**/*.scss', 'sass');
watch('src/**/*.jade', 'jade');
watch('src/**/*.js', 'webpack');
});
gulp.task('default', ['clean', 'webpack', 'assets', 'sass', 'jade']);
doctype html
html(ng-app="foo")
head
title your app
link(href="./index.css" rel="stylesheet" type="text/css")
link(href="images/icon.png" rel="icon" type="image/png")
body
header#topbar.row
.container
h1
img(src="images/icon.png" valign="middle" width="50")
| your app
div(ui-view="")
//- bower:js
//- endinject
script(src="./main.js")
var webpack = require("webpack");
module.exports = {
target: 'web',
entry: './src/index.js',
output: {
filename: "[name].js"
},
resolve: {
extensions: ['', '.js']
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment