Skip to content

Instantly share code, notes, and snippets.

@kuzzmi
Last active August 29, 2015 14:25
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 kuzzmi/82542d02b25b657ba01e to your computer and use it in GitHub Desktop.
Save kuzzmi/82542d02b25b657ba01e to your computer and use it in GitHub Desktop.
Project bootstrap files
{
"node" : true,
"browser" : true,
"esnext" : true,
"bitwise" : false,
"camelcase" : true,
"curly" : true,
"eqeqeq" : true,
"immed" : true,
"indent" : 4,
"latedef" : true,
"newcap" : true,
"noarg" : true,
"quotmark" : "single",
"regexp" : true,
"undef" : true,
"unused" : true,
"strict" : true,
"trailing" : true,
"smarttabs" : true,
"jquery" : true,
"globals": {
"$" : false,
"angular" : false,
"browser" : false,
"repeater" : false,
"element" : false,
"inject" : false,
"afterEach" : false,
"beforeEach" : false,
"confirm" : false,
"context" : false,
"describe" : false,
"expect" : false,
"it" : false,
"jasmine" : false,
"JSHINT" : false,
"Masonry" : false,
"interact" : false,
"mostRecentAjaxRequest" : false,
"qq" : false,
"runs" : false,
"spyOn" : false,
"spyOnEvent" : false,
"waitsFor" : false,
"xdescribe" : false,
"xit" : false
}
}
'use strict';
module.exports = function(grunt) {
// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
// Time how long tasks take.
require('time-grunt')(grunt);
// Configurable paths for the application
// We can use bower.json to store this, for example.
// require('./bower.json').appPath
var appConfig = {
src: 'src',
dist: 'dist',
tmp: '.tmp'
};
// Define the configuration for all the tasks
grunt.initConfig({
// Project settings
root: appConfig,
// Watches files for changes and runs tasks based on the changed files
watch: {
bower: {
files: ['bower.json'],
tasks: ['wiredep']
},
js: {
files: [
'<%= root.src %>/**/*.js'
],
tasks: ['newer:jshint:all'],
options: {
livereload: '<%= connect.options.livereload %>'
}
},
css: {
files: ['<%= root.src %>/styles/{,*/}*.css'],
tasks: ['autoprefixer']
},
compass: {
files: ['<%= root.src %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
},
gruntfile: {
files: ['Gruntfile.js']
},
livereload: {
files: [
'<%= root.src %>/**.html',
'<%= root.src %>/{,*/}*.css',
'<%= root.tmp =>/styles/{,*/}*.css',
'<%= root.src %>/assets/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
],
options: {
livereload: '<%= connect.options.livereload %>'
}
}
},
// The actual grunt server settings
connect: {
options: {
port: 8099,
hostname: '0.0.0.0',
livereload: 35729
},
livereload: {
options: {
open: true,
middleware: function(connect) {
return [
connect.static('<%= root.tmp =>'),
connect().use(
'/bower_components',
connect.static('./bower_components')
),
connect.static(appConfig.src)
];
}
}
},
dist: {
options: {
open: true,
base: '<%= root.dist %>'
}
}
},
// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
'Gruntfile.js',
'<%= root.src %>/**/*.js'
]
},
test: {
options: {
jshintrc: 'test/.jshintrc'
},
src: ['test/spec/{,*/}*.js']
}
},
// Empties folders to start fresh
clean: {
dist: {
files: [{
dot: true,
src: [
'<%= root.tmp =>',
'<%= root.dist %>/{,*/}*',
'!<%= root.dist %>/.git*'
]
}]
},
server: '<%= root.tmp =>'
},
// Add vendor prefixed styles
autoprefixer: {
options: {
browsers: ['last 2 versions']
},
dist: {
files: [{
expand: true,
cwd: '<%= root.tmp =>/styles/',
src: '{,*/}*.css',
dest: '<%= root.tmp =>/styles/'
}]
}
},
// Automatically inject Bower components into the app
wiredep: {
app: {
src: ['<%= root.src %>/index.html'],
ignorePath: /\.\.\//
},
sass: {
src: ['<%= root.src %>/styles/{,*/}*.{scss,sass}'],
ignorePath: /(\.\.\/){1,2}bower_components\//
}
},
// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
sassDir: '<%= root.src %>/styles',
cssDir: '<%= root.tmp =>/styles',
generatedImagesDir: '<%= root.tmp =>/img/generated',
imagesDir: '<%= root.src %>/assets/img',
javascriptsDir: [
'<%= root.src %>/app/',
'<%= root.src %>/common/'
],
fontsDir: '<%= root.src %>/styles/fonts',
importPath: './bower_components',
httpImagesPath: '/img',
httpGeneratedImagesPath: '/img/generated',
httpFontsPath: '/styles/fonts',
relativeAssets: false,
assetCacheBuster: false,
raw: 'Sass::Script::Number.precision = 10\n'
},
dist: {
options: {
generatedImagesDir: '<%= root.dist %>/img/generated'
}
},
server: {
options: {
debugInfo: true
}
}
},
// Renames files for browser caching purposes
filerev: {
dist: {
src: [
'<%= root.dist %>/js/**/*.js',
'<%= root.dist %>/styles/{,*/}*.css',
'<%= root.dist %>/assets/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
// Reads HTML for usemin blocks to enable smart builds that automatically
// concat, minify and revision files. Creates configurations in memory so
// additional tasks can operate on them
useminPrepare: {
html: '<%= root.src %>/index.html',
options: {
dest: '<%= root.dist %>',
flow: {
html: {
steps: {
js: ['concat', 'uglifyjs'],
css: ['cssmin']
},
post: {}
}
}
}
},
// Performs rewrites based on filerev and the useminPrepare configuration
usemin: {
html: ['<%= root.dist %>/**/*.html'],
css: ['<%= root.dist %>/styles/{,*/}*.css'],
options: {
assetsDirs: [
'<%= root.dist %>',
'<%= root.dist %>/assets/img'
]
}
},
htmlmin: {
dist: {
options: {
collapseWhitespace: true,
conservativeCollapse: true,
collapseBooleanAttributes: true,
removeCommentsFromCDATA: true,
removeComments: true,
removeOptionalTags: true
},
files: [{
expand: true,
cwd: '<%= root.dist %>',
src: [
'**/*.html',
],
dest: '<%= root.dist %>'
}]
}
},
// Replace Google CDN references
cdnify: {
dist: {
html: ['<%= root.dist %>/*.html']
}
},
// Copies remaining files to places other tasks can use
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= root.src %>',
dest: '<%= root.dist %>',
src: [
'*.{ico,png,txt}',
'.htaccess',
'*.html',
'config.js',
'app/**/*.html',
'assets/img/{,*/}*.{png,jpg,jpeg,gif,webp}',
'styles/fonts/*'
]
}, {
expand: true,
cwd: '<%= root.tmp =>/img',
dest: '<%= root.dist %>/img',
src: ['generated/*']
}, {
expand: true,
cwd: 'bower_components/bootstrap/dist',
src: 'fonts/*',
dest: '<%= root.dist %>'
}]
},
styles: {
expand: true,
cwd: '<%= root.src %>/styles',
dest: '<%= root.tmp =>/styles/',
src: '{,*/}*.css'
}
},
// Run some tasks in parallel to speed up the build process
concurrent: {
server: [
'compass:server'
],
test: [
'compass'
],
dist: [
'compass:dist'
]
}
});
grunt.registerTask('serve', 'Compile then start a connect web server',
function() {
grunt.task.run([
'clean:server',
'wiredep',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'watch'
]);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment