2015-09-22 03:23:27 +03:00
// Generated on 2015-09-21 using
// generator-webapp 1.1.0
'use strict' ;
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// If you want to recursively match all subfolders, use:
// 'test/spec/**/*.js'
module . exports = function ( grunt ) {
// Time how long tasks take. Can help when optimizing build times
require ( 'time-grunt' ) ( grunt ) ;
// Automatically load required grunt tasks
require ( 'jit-grunt' ) ( grunt , {
useminPrepare : 'grunt-usemin'
} ) ;
// Configurable paths
var config = {
app : 'app' ,
dist : 'dist'
} ;
// Define the configuration for all the tasks
grunt . initConfig ( {
// Project settings
config : config ,
// Watches files for changes and runs tasks based on the changed files
watch : {
bower : {
files : [ 'bower.json' ] ,
tasks : [ 'wiredep' ]
} ,
babel : {
2015-09-25 05:55:07 +03:00
// files: ['<%= config.app %>/js/{,*/}*.js'],
files : [ ] ,
2015-09-22 03:23:27 +03:00
tasks : [ 'babel:dist' ]
} ,
babelTest : {
2015-09-25 05:55:07 +03:00
// files: ['test/spec/{,*/}*.js'],
files : [ ] ,
2015-09-22 03:23:27 +03:00
tasks : [ 'babel:test' , 'test:watch' ]
} ,
gruntfile : {
files : [ 'Gruntfile.js' ]
} ,
sass : {
2015-09-25 05:55:07 +03:00
files : [ '<%= config.app %>/css/{,*/}*.{scss,sass}' ] ,
2015-09-22 03:23:27 +03:00
tasks : [ 'sass' , 'postcss' ]
} ,
2015-09-25 05:55:07 +03:00
css : {
files : [ '<%= config.app %>/css/{,*/}*.css' ] ,
tasks : [ 'newer:copy:css' , 'postcss' ]
2015-09-22 03:23:27 +03:00
}
} ,
browserSync : {
options : {
notify : false ,
background : true ,
watchOptions : {
ignored : ''
}
} ,
livereload : {
options : {
files : [
'<%= config.app %>/{,*/}*.html' ,
2015-09-25 05:55:07 +03:00
'.tmp/css/{,*/}*.css' ,
'<%= config.app %>/img/{,*/}*' ,
'.tmp/js/{,*/}*.js'
2015-09-22 03:23:27 +03:00
] ,
port : 9000 ,
server : {
baseDir : [ '.tmp' , config . app ] ,
routes : {
'/bower_components' : './bower_components'
}
}
}
} ,
test : {
options : {
port : 9001 ,
open : false ,
logLevel : 'silent' ,
host : 'localhost' ,
server : {
baseDir : [ '.tmp' , './test' , config . app ] ,
routes : {
'/bower_components' : './bower_components'
}
}
}
} ,
dist : {
options : {
background : false ,
server : '<%= config.dist %>'
}
}
} ,
// Empties folders to start fresh
clean : {
dist : {
files : [ {
dot : true ,
src : [
'.tmp' ,
'<%= config.dist %>/*' ,
'!<%= config.dist %>/.git*'
]
} ]
} ,
server : '.tmp'
} ,
2015-09-25 05:55:07 +03:00
// Make sure code css are up to par and there are no obvious mistakes
2015-09-22 03:23:27 +03:00
eslint : {
target : [
'Gruntfile.js' ,
2015-09-25 05:55:07 +03:00
// '<%= config.app %>/js/{,*/}*.js',
'!<%= config.app %>/js/vendor/*' ,
2015-09-22 03:23:27 +03:00
'test/spec/{,*/}*.js'
]
} ,
// Mocha testing framework configuration options
mocha : {
all : {
options : {
run : true ,
urls : [ 'http://<%= browserSync.test.options.host %>:<%= browserSync.test.options.port %>/index.html' ]
}
}
} ,
// Compiles ES6 with Babel
babel : {
options : {
sourceMap : true
} ,
dist : {
files : [ {
expand : true ,
2015-09-25 05:55:07 +03:00
cwd : '<%= config.app %>/js' ,
src : '{,*/}*.jss' ,
dest : '.tmp/js' ,
ext : '.jss'
2015-09-22 03:23:27 +03:00
} ]
} ,
test : {
files : [ {
expand : true ,
cwd : 'test/spec' ,
2015-09-25 05:55:07 +03:00
src : '{,*/}*.jss' ,
2015-09-22 03:23:27 +03:00
dest : '.tmp/spec' ,
2015-09-25 05:55:07 +03:00
ext : '.jss'
2015-09-22 03:23:27 +03:00
} ]
}
} ,
// Compiles Sass to CSS and generates necessary files if requested
sass : {
options : {
sourceMap : true ,
sourceMapEmbed : true ,
sourceMapContents : true ,
includePaths : [ '.' ]
} ,
dist : {
files : [ {
expand : true ,
2015-09-25 05:55:07 +03:00
cwd : '<%= config.app %>/css' ,
2015-09-22 03:23:27 +03:00
src : [ '*.{scss,sass}' ] ,
2015-09-25 05:55:07 +03:00
dest : '.tmp/css' ,
2015-09-22 03:23:27 +03:00
ext : '.css'
} ]
}
} ,
postcss : {
options : {
map : true ,
processors : [
2015-09-25 05:55:07 +03:00
// Add vendor prefixed css
2015-09-22 03:23:27 +03:00
require ( 'autoprefixer' ) ( {
browsers : [ '> 1%' , 'last 2 versions' , 'Firefox ESR' ]
} )
]
} ,
dist : {
files : [ {
expand : true ,
2015-09-25 05:55:07 +03:00
cwd : '.tmp/css/' ,
2015-09-22 03:23:27 +03:00
src : '{,*/}*.css' ,
2015-09-25 05:55:07 +03:00
dest : '.tmp/css/'
2015-09-22 03:23:27 +03:00
} ]
}
} ,
// Automatically inject Bower components into the HTML file
wiredep : {
app : {
src : [ '<%= config.app %>/index.html' ] ,
exclude : [ 'bootstrap.js' ] ,
ignorePath : /^(\.\.\/)*\.\./
} ,
sass : {
2015-09-25 05:55:07 +03:00
src : [ '<%= config.app %>/css/{,*/}*.{scss,sass}' ] ,
2015-09-22 03:23:27 +03:00
ignorePath : /^(\.\.\/)+/
}
} ,
// Renames files for browser caching purposes
filerev : {
dist : {
src : [
2015-09-25 05:55:07 +03:00
'<%= config.dist %>/js/{,*/}*.js' ,
'<%= config.dist %>/css/{,*/}*.css' ,
'<%= config.dist %>/img/{,*/}*.*' ,
'<%= config.dist %>/css/fonts/{,*/}*.*' ,
2015-09-22 03:23:27 +03:00
'<%= config.dist %>/*.{ico,png}'
]
}
} ,
// 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 : {
options : {
dest : '<%= config.dist %>'
} ,
html : '<%= config.app %>/index.html'
} ,
// Performs rewrites based on rev and the useminPrepare configuration
usemin : {
options : {
assetsDirs : [
'<%= config.dist %>' ,
2015-09-25 05:55:07 +03:00
'<%= config.dist %>/img' ,
'<%= config.dist %>/css'
2015-09-22 03:23:27 +03:00
]
} ,
html : [ '<%= config.dist %>/{,*/}*.html' ] ,
2015-09-25 05:55:07 +03:00
css : [ '<%= config.dist %>/css/{,*/}*.css' ]
2015-09-22 03:23:27 +03:00
} ,
// The following *-min tasks produce minified files in the dist folder
imagemin : {
dist : {
files : [ {
expand : true ,
2015-09-25 05:55:07 +03:00
cwd : '<%= config.app %>/img' ,
2015-09-22 03:23:27 +03:00
src : '{,*/}*.{gif,jpeg,jpg,png}' ,
2015-09-25 05:55:07 +03:00
dest : '<%= config.dist %>/img'
2015-09-22 03:23:27 +03:00
} ]
}
} ,
svgmin : {
dist : {
files : [ {
expand : true ,
2015-09-25 05:55:07 +03:00
cwd : '<%= config.app %>/img' ,
2015-09-22 03:23:27 +03:00
src : '{,*/}*.svg' ,
2015-09-25 05:55:07 +03:00
dest : '<%= config.dist %>/img'
2015-09-22 03:23:27 +03:00
} ]
}
} ,
htmlmin : {
dist : {
options : {
collapseBooleanAttributes : true ,
collapseWhitespace : true ,
conservativeCollapse : true ,
removeAttributeQuotes : true ,
removeCommentsFromCDATA : true ,
removeEmptyAttributes : true ,
removeOptionalTags : true ,
2015-09-25 05:55:07 +03:00
// true would impact css with attribute selectors
2015-09-22 03:23:27 +03:00
removeRedundantAttributes : false ,
useShortDoctype : true
} ,
files : [ {
expand : true ,
cwd : '<%= config.dist %>' ,
src : '{,*/}*.html' ,
dest : '<%= config.dist %>'
} ]
}
} ,
// By default, your `index.html`'s <!-- Usemin block --> will take care
// of minification. These next options are pre-configured if you do not
// wish to use the Usemin blocks.
// cssmin: {
// dist: {
// files: {
2015-09-25 05:55:07 +03:00
// '<%= config.dist %>/css/main.css': [
// '.tmp/css/{,*/}*.css',
// '<%= config.app %>/css/{,*/}*.css'
2015-09-22 03:23:27 +03:00
// ]
// }
// }
// },
// uglify: {
// dist: {
// files: {
2015-09-25 05:55:07 +03:00
// '<%= config.dist %>/js/js.js': [
// '<%= config.dist %>/js/js.js'
2015-09-22 03:23:27 +03:00
// ]
// }
// }
// },
// concat: {
// dist: {}
// },
// Copies remaining files to places other tasks can use
copy : {
dist : {
files : [ {
expand : true ,
dot : true ,
cwd : '<%= config.app %>' ,
dest : '<%= config.dist %>' ,
src : [
'*.{ico,png,txt}' ,
2015-09-25 05:55:07 +03:00
'img/{,*/}*.webp' ,
2015-09-22 03:23:27 +03:00
'{,*/}*.html' ,
2015-09-25 05:55:07 +03:00
'css/fonts/{,*/}*.*'
2015-09-22 03:23:27 +03:00
]
} , {
expand : true ,
dot : true ,
cwd : '.' ,
src : 'bower_components/bootstrap-sass/assets/fonts/bootstrap/*' ,
dest : '<%= config.dist %>'
} ]
}
} ,
// Run some tasks in parallel to speed up build process
concurrent : {
server : [
2015-09-25 05:55:07 +03:00
// 'babel:dist',
2015-09-22 03:23:27 +03:00
'sass'
] ,
test : [
2015-09-25 05:55:07 +03:00
//'babel'
2015-09-22 03:23:27 +03:00
] ,
dist : [
2015-09-25 05:55:07 +03:00
//'babel',
2015-09-22 03:23:27 +03:00
'sass' ,
'imagemin' ,
'svgmin'
]
}
} ) ;
grunt . registerTask ( 'serve' , 'start the server and preview your app' , function ( target ) {
if ( target === 'dist' ) {
return grunt . task . run ( [ 'build' , 'browserSync:dist' ] ) ;
}
grunt . task . run ( [
'clean:server' ,
'wiredep' ,
'concurrent:server' ,
'postcss' ,
'browserSync:livereload' ,
'watch'
] ) ;
} ) ;
grunt . registerTask ( 'server' , function ( target ) {
grunt . log . warn ( 'The `server` task has been deprecated. Use `grunt serve` to start a server.' ) ;
grunt . task . run ( [ target ? ( 'serve:' + target ) : 'serve' ] ) ;
} ) ;
grunt . registerTask ( 'test' , function ( target ) {
if ( target !== 'watch' ) {
grunt . task . run ( [
'clean:server' ,
'concurrent:test' ,
'postcss'
] ) ;
}
grunt . task . run ( [
'browserSync:test' ,
'mocha'
] ) ;
} ) ;
grunt . registerTask ( 'build' , [
'clean:dist' ,
'wiredep' ,
'useminPrepare' ,
'concurrent:dist' ,
'postcss' ,
'concat' ,
'cssmin' ,
2015-09-22 20:53:56 +03:00
// 'uglify',
2015-09-25 05:55:07 +03:00
'copy:dist'
// 'filerev',
// 'usemin'
2015-09-22 03:23:27 +03:00
// 'htmlmin'
] ) ;
grunt . registerTask ( 'default' , [
'newer:eslint' ,
'test' ,
'build'
] ) ;
} ;