Last active
July 15, 2016 12:10
-
-
Save jmartsch/8038035 to your computer and use it in GitHub Desktop.
Gruntfile with browser-sync and assemble for static html files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated on 2013-10-28 using generator-bootstrap-less 3.0.3 | |
"use strict" | |
#lrSnippet = require("grunt-contrib-livereload/lib/utils").livereloadSnippet | |
#mountFolder = (connect, dir) -> | |
# connect.static require("path").resolve(dir) | |
# # Globbing | |
# for performance reasons we're only matching one level down: | |
# 'test/spec/{,*/}*.js' | |
# use this if you want to match all subfolders: | |
# 'test/spec/**/*.js' | |
module.exports = (grunt) -> | |
# load all grunt tasks | |
grunt.loadNpmTasks('assemble'); | |
require("matchdep").filterDev("grunt-*").forEach grunt.loadNpmTasks | |
# configurable paths | |
yeomanConfig = | |
app: "app" | |
dist: "dist" | |
grunt.initConfig | |
yeoman: yeomanConfig | |
assemble: | |
options: | |
flatten: true | |
layout: "layout.hbs" | |
layoutdir: "<%= yeoman.app %>/templates/layouts" | |
assets: "dist/images" | |
partials: ["<%= yeoman.app %>/templates/includes/*.hbs"] | |
dist: | |
files: | |
"<%= yeoman.app %>/": ["<%= yeoman.app %>/templates/*.hbs"] | |
server: | |
files: | |
"<%= yeoman.app %>/": ["<%= yeoman.app %>/templates/*.hbs"] | |
watch: | |
coffee: | |
files: ["<%= yeoman.app %>/scripts/{,*/}*.coffee"] | |
tasks: ["coffee"] | |
assemble: | |
files: | |
['<%= yeoman.app %>/templates/layouts/*.hbs', | |
'<%= yeoman.app %>/templates/*.hbs', | |
'<%= yeoman.app %>/templates/includes/*.hbs'] | |
tasks: ['assemble:server'] | |
recess: | |
files: ["<%= yeoman.app %>/styles/{,*/}*.less"] | |
tasks: ["recess"] | |
# livereload: { | |
# files: [ | |
# '<%= yeoman.app %>/*.html', | |
# '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css', | |
# '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js', | |
# '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' | |
# ], | |
# tasks: ['livereload'] | |
# } | |
browser_sync: | |
options: | |
watchTask: true | |
debugInfo: true | |
notify: true | |
proxy: | |
host: "192.168.178.24" | |
# host: "192.168.178.24", | |
# proxy: { | |
# // Your existing vhost setup | |
# proxy has bugs right now, but they will be fixed soon | |
# after that, the needed script are inserted automatically into the page | |
# host: "web", | |
# }, | |
ghostMode: | |
scroll: true | |
links: true | |
forms: true | |
files: | |
src: ["<%= yeoman.app %>/styles/*.css", ".tmp/*.html", "<%= yeoman.app %>/images/**/*.jpg", | |
"<%= yeoman.app %>/images/**/*.png", "<%= yeoman.app %>/scripts/**/*.js", "**/*.php", "**/*.html"] | |
connect: | |
options: | |
port: 9000 | |
# change this to '0.0.0.0' to access the server from outside | |
hostname: "0.0.0.0" | |
# livereload: | |
# options: | |
# middleware: (connect) -> | |
# [lrSnippet, mountFolder(connect, ".tmp"), mountFolder(connect, "app")] | |
test: | |
options: | |
middleware: (connect) -> | |
[mountFolder(connect, ".tmp"), mountFolder(connect, "test")] | |
dist: | |
options: | |
middleware: (connect) -> | |
[mountFolder(connect, "dist")] | |
open: | |
server: | |
path: "http://localhost:<%= connect.options.port %>" | |
clean: | |
dist: | |
files: [ | |
dot: true | |
src: [".tmp", "<%= yeoman.dist %>/*", "!<%= yeoman.dist %>/.git*"] | |
] | |
server: ".tmp" | |
jshint: | |
options: | |
jshintrc: ".jshintrc" | |
all: ["Gruntfile.js", "<%= yeoman.app %>/scripts/{,*/}*.js", "!<%= yeoman.app %>/scripts/vendor/*", | |
"test/spec/{,*/}*.js"] | |
mocha: | |
all: | |
options: | |
run: true | |
urls: ["http://localhost:<%= connect.options.port %>/index.html"] | |
coffee: | |
dist: | |
files: [ | |
expand: true | |
cwd: "<%= yeoman.app %>/scripts" | |
src: "{,*/}*.coffee" | |
dest: "<%= yeoman.app %>/scripts" | |
ext: ".js" | |
] | |
recess: | |
dist: | |
options: | |
compile: true | |
files: | |
"<%= yeoman.app %>/styles/main.css": ["<%= yeoman.app %>/styles/main.less"] | |
useminPrepare: | |
html: "<%= yeoman.app %>/*.html" | |
options: | |
dest: "<%= yeoman.dist %>" | |
usemin: | |
html: ["<%= yeoman.dist %>/{,*/}*.html"] | |
css: ["<%= yeoman.dist %>/styles/{,*/}*.css"] | |
options: | |
dirs: ["<%= yeoman.dist %>"] | |
imagemin: | |
dist: | |
files: [ | |
expand: true | |
cwd: "<%= yeoman.app %>/images" | |
src: "{,*/}*.{png,jpg,jpeg}" | |
dest: "<%= yeoman.dist %>/images" | |
] | |
svgmin: | |
dist: | |
files: [ | |
expand: true | |
cwd: "<%= yeoman.app %>/images" | |
src: "{,*/}*.svg" | |
dest: "<%= yeoman.dist %>/images" | |
] | |
cssmin: | |
dist: | |
files: | |
"<%= yeoman.dist %>/styles/main.css": [".tmp/styles/{,*/}*.css", "<%= yeoman.app %>/styles/{,*/}*.css"] | |
htmlmin: | |
dist: | |
options: {} | |
#removeCommentsFromCDATA: true, | |
# // https://github.com/yeoman/grunt-usemin/issues/44 | |
# //collapseWhitespace: true, | |
# collapseBooleanAttributes: true, | |
# removeAttributeQuotes: true, | |
# removeRedundantAttributes: true, | |
# useShortDoctype: true, | |
# removeEmptyAttributes: true, | |
# removeOptionalTags: true | |
files: [ | |
expand: true | |
cwd: ".tmp" | |
src: "*.html" | |
dest: "<%= yeoman.dist %>" | |
] | |
copy: | |
dist: | |
files: [ | |
expand: true | |
dot: true | |
cwd: "<%= yeoman.app %>" | |
dest: "<%= yeoman.dist %>" | |
src: ["*.{ico,png,txt,php,html}", "fonts/{,*/}*.*", ".htaccess", "images/{,*/}*.{webp,gif}", "PHPMailer/*.php", | |
"PHPMailer/language/**", "PHPMailer/extras/**"] | |
] | |
# { | |
# expand: true, | |
# dot: true, | |
# cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts/', | |
# dest: '<%= yeoman.app %>/fonts/fontawesome', | |
# src: ['*.*'] | |
# } | |
server: | |
files: [ | |
# { | |
# expand: true, | |
# dot: true, | |
# cwd: '<%= yeoman.app %>/bower_components/font-awesome/font/', | |
# dest: '<%= yeoman.app %>/fonts/font-awesome', | |
# src: ['*'] | |
# }, | |
expand: true | |
dot: true | |
cwd: "<%= yeoman.app %>/bower_components/bootstrap/fonts/" | |
dest: "<%= yeoman.app %>/fonts/glyphicons" | |
src: ["*"] | |
] | |
concurrent: | |
dist: ["coffee", "recess", "assemble", "imagemin", "svgmin", "htmlmin"] | |
grunt.renameTask "regarde", "watch" | |
# grunt.registerTask "server", (target) -> | |
# return grunt.task.run(["build", "open", "connect:dist:keepalive"]) if target is "dist" | |
# grunt.task.run ["clean:server", "coffee", "recess", "copy:server", "livereload-start", "connect:livereload", "open", "php:watch", "watch"] | |
grunt.registerTask "test", ["clean:server", "coffee", "recess", "copy:server", "connect:test", "mocha"] | |
# 'clean:server', | |
# 'recess', | |
grunt.registerTask "default", ["browser_sync", "watch"] | |
# 'rev', | |
grunt.registerTask "build", | |
["clean:dist", "concurrent:dist", "useminPrepare", "cssmin", "concat", "uglify", "copy:dist", "usemin"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment