Skip to content

Instantly share code, notes, and snippets.

@tonyseek
Created January 18, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyseek/9d7db6855101b003c6e5 to your computer and use it in GitHub Desktop.
Save tonyseek/9d7db6855101b003c6e5 to your computer and use it in GitHub Desktop.
Flask + Browserify + Gulp + Stylus
gulp = require 'gulp'
uglify = require 'gulp-uglify'
sourcemaps = require 'gulp-sourcemaps'
stylus = require 'gulp-stylus'
rename = require 'gulp-rename'
source = require 'vinyl-source-stream'
buffer = require 'vinyl-buffer'
browserify = require 'browserify'
del = require 'del'
pkginfo = require './package.json'
gulp.task 'build', ['build:scripts', 'build:stylesheets', 'build:images']
gulp.task 'build:scripts', () ->
browserify(entries: pkginfo.assets.scripts, debug: true).bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init(loadMaps: true))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(pkginfo.main))
gulp.task 'build:stylesheets', () ->
gulp.src(pkginfo.assets.stylesheets)
.pipe(sourcemaps.init(loadMaps: true))
.pipe(stylus(
compress: true,
paths: pkginfo.stylus.paths,
'include css': true
))
.pipe(rename('bundle.css'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(pkginfo.main))
gulp.task 'build:images', () ->
gulp.src(pkginfo.assets.images)
.pipe(gulp.dest(pkginfo.main))
gulp.task 'watch', ['build'], () ->
gulp.watch(pkginfo.assets.scripts, ['build:scripts'])
gulp.watch(pkginfo.assets.stylesheets, ['build:stylesheets'])
gulp.task 'clean', (cb) ->
del([pkginfo.main + '/*', '!.gitignore'], cb)
{
"name": "APP-NAME-HERE",
"scripts": {},
"private": true,
"dependencies": {
"bootstrap": "^3.3.1",
"bootstrap-select": "git+https://github.com/tonyseek/bootstrap-select.git#umd",
"jquery": "^2.1.3"
},
"devDependencies": {
"browserify": "^8.1.0",
"coffee-script": "^1.8.0",
"coffeeify": "^1.0.0",
"del": "^1.1.1",
"gulp": "^3.8.10",
"gulp-rename": "^1.2.0",
"gulp-sourcemaps": "^1.3.0",
"gulp-stylus": "^1.3.6",
"gulp-uglify": "^1.0.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.0.0"
},
"browserify": {
"transform": [
"coffeeify"
],
"extensions": [
".js",
".coffee"
],
"paths": [
"./node_modules",
"./f2e/scripts"
]
},
"stylus": {
"paths": [
"./node_modules/bootstrap/dist/css",
"./node_modules/bootstrap-select/dist/css"
]
},
"main": "./APP-NAME-HERE/static/",
"assets": {
"scripts": [
"./f2e/scripts/home.coffee",
"./f2e/scripts/about.coffee"
],
"stylesheets": [
"./f2e/stylesheets/home.styl",
"./f2e/stylesheets/about.styl"
],
"images": []
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment