pure/Gruntfile.js

310 lines
8.1 KiB
JavaScript
Raw Normal View History

2013-05-09 21:56:32 +00:00
module.exports = function (grunt) {
// -- Config -------------------------------------------------------------------
grunt.initConfig({
nick : 'pure',
pkg : grunt.file.readJSON('package.json'),
bower: grunt.file.readJSON('bower.json'),
2013-05-09 21:56:32 +00:00
2014-02-06 22:44:02 +00:00
// -- bower.json Config ---------------------------------------------------------
2013-05-09 21:56:32 +00:00
2014-02-06 22:44:02 +00:00
bower_json: {
release: {
values: {
main: 'pure.css'
},
dest: 'build/'
2014-02-06 22:44:02 +00:00
}
},
2013-05-09 21:56:32 +00:00
// -- Clean Config ---------------------------------------------------------
clean: {
build : ['build/'],
build_res: ['build/*-r.css'],
release : ['release/<%= pkg.version %>/']
},
// -- Copy Config ----------------------------------------------------------
2013-05-09 21:56:32 +00:00
copy: {
build: {
src : 'src/**/css/*.css',
dest : 'build/',
expand : true,
flatten: true
2014-02-05 17:52:39 +00:00
},
2014-02-05 17:52:39 +00:00
release: {
src : '{LICENSE.md,README.md,HISTORY.md}',
dest: 'build/'
}
},
2013-05-09 21:56:32 +00:00
// -- Concat Config --------------------------------------------------------
concat: {
build: {
files: [
{'build/base.css': [
'bower_components/normalize-css/normalize.css',
'build/base.css'
]},
{'build/buttons.css': [
'build/buttons-core.css',
'build/buttons.css'
]},
{'build/forms-nr.css': [
'build/forms.css'
]},
{'build/forms.css': [
'build/forms-nr.css',
'build/forms-r.css'
]},
{'build/grids.css': [
'build/grids-core.css',
'build/grids-units.css'
]},
{'build/menus.css': [
2015-01-29 23:23:21 +00:00
'build/menus-core.css',
'build/menus-horizontal.css',
'build/menus-dropdown.css',
'build/menus-scrollable.css',
'build/menus-skin.css',
]},
2013-05-09 21:56:32 +00:00
// Rollups
{'build/<%= nick %>.css': [
'build/base.css',
'build/grids.css',
'build/buttons.css',
'build/forms.css',
'build/menus.css',
'build/tables.css'
]},
{'build/<%= nick %>-nr.css': [
'build/base.css',
'build/grids.css',
'build/buttons.css',
'build/forms-nr.css',
2015-01-29 23:23:21 +00:00
'build/menus.css',
'build/tables.css'
]}
]
}
},
2013-05-09 21:56:32 +00:00
// -- PostCSS Config --------------------------------------------------------
postcss: {
options: {
processors: [
require('autoprefixer')({browsers: ['last 2 versions', 'ie >= 8', 'iOS >= 6', 'Android >= 4']})
]
},
dist: {
src: 'build/*.css'
}
},
// -- CSSLint Config -------------------------------------------------------
csslint: {
options: {
csslintrc: '.csslintrc'
},
base : ['src/base/css/*.css'],
buttons: ['src/buttons/css/*.css'],
forms : ['src/forms/css/*.css'],
grids : ['src/grids/css/*.css'],
menus : ['src/menus/css/*.css'],
tables : ['src/tables/css/*.css']
},
// -- CSSMin Config --------------------------------------------------------
cssmin: {
options: {
noAdvanced: true
2013-05-09 21:56:32 +00:00
},
files: {
expand: true,
src : 'build/*.css',
ext : '-min.css'
}
},
// -- Compress Config ------------------------------------------------------
compress: {
release: {
options: {
archive: 'release/<%= pkg.version %>/<%= nick %>-<%= pkg.version %>.tar.gz'
},
expand : true,
flatten: true,
2014-02-05 17:52:39 +00:00
src : 'build/*',
dest : '<%= nick %>/<%= pkg.version %>/'
}
},
// -- License Config -------------------------------------------------------
license: {
normalize: {
options: {
banner: [
'/*!',
'normalize.css v<%= bower.devDependencies["normalize-css"] %> | MIT License | git.io/normalize',
'Copyright (c) Nicolas Gallagher and Jonathan Neal',
'*/\n'
].join('\n')
},
expand: true,
cwd : 'build/',
src : ['base*.css', '<%= nick %>*.css']
},
yahoo: {
options: {
banner: [
'/*!',
'Pure v<%= pkg.version %>',
'Copyright 2013 Yahoo!',
'Licensed under the BSD License.',
'https://github.com/pure-css/pure/blob/master/LICENSE.md',
'*/\n'
].join('\n')
},
expand: true,
src : ['build/*.css']
}
},
2014-02-18 16:55:22 +00:00
// -- Pure Grids Units Config ----------------------------------------------
2014-02-18 16:55:22 +00:00
pure_grids: {
default_units: {
dest: 'build/grids-units.css',
options: {
2014-02-18 16:55:22 +00:00
units: [5, 24]
}
},
responsive: {
dest: 'build/grids-responsive.css',
options: {
mediaQueries: {
sm: 'screen and (min-width: 35.5em)', // 568px
md: 'screen and (min-width: 48em)', // 768px
lg: 'screen and (min-width: 64em)', // 1024px
xl: 'screen and (min-width: 80em)' // 1280px
}
}
2014-02-18 16:55:22 +00:00
}
2013-11-18 19:46:19 +00:00
},
2014-03-07 18:15:06 +00:00
// -- Strip Media Queries Config -------------------------------------------
stripmq: {
all: {
files: {
//follows the pattern 'destination': ['source']
'build/grids-responsive-old-ie.css':
['build/grids-responsive.css']
}
}
},
// -- CSS Selectors Config -------------------------------------------------
css_selectors: {
base: {
src : 'build/base.css',
dest: 'build/base-context.css',
options: {
mutations: [{prefix: '.pure'}]
2013-05-09 21:56:32 +00:00
}
}
2013-06-05 22:51:10 +00:00
},
// -- Watch/Observe Config -------------------------------------------------
2013-06-05 22:51:10 +00:00
observe: {
2013-06-05 22:51:10 +00:00
src: {
files: 'src/**/css/*.css',
tasks: ['test', 'suppress', 'build'],
2013-06-05 22:51:10 +00:00
options: {
interrupt: true
}
}
2013-05-09 21:56:32 +00:00
}
});
// -- Main Tasks ---------------------------------------------------------------
2013-11-18 19:45:37 +00:00
// npm tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-csslint');
2013-05-09 21:56:32 +00:00
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-compress');
2013-06-05 22:51:10 +00:00
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-css-selectors');
grunt.loadNpmTasks('grunt-postcss');
2014-02-18 16:55:22 +00:00
grunt.loadNpmTasks('grunt-pure-grids');
2014-03-07 18:15:06 +00:00
grunt.loadNpmTasks('grunt-stripmq');
2013-05-09 21:56:32 +00:00
2013-11-18 19:45:37 +00:00
// Local tasks.
grunt.loadTasks('tasks/');
2013-05-09 21:56:32 +00:00
grunt.registerTask('default', ['import', 'test', 'build']);
2013-11-18 19:45:37 +00:00
grunt.registerTask('import', ['bower_install']);
grunt.registerTask('test', ['csslint']);
grunt.registerTask('build', [
'clean:build',
'copy:build',
2014-02-18 16:55:22 +00:00
'pure_grids',
2014-03-07 18:15:06 +00:00
'stripmq',
'concat:build',
'clean:build_res',
'css_selectors:base',
'postcss',
'cssmin',
'license'
]);
// Makes the `watch` task run a build first.
grunt.renameTask('watch', 'observe');
grunt.registerTask('watch', ['default', 'observe']);
grunt.registerTask('release', [
'default',
'clean:release',
2014-02-05 17:52:39 +00:00
'copy:release',
'bower_json:release',
'compress:release'
]);
2013-05-09 21:56:32 +00:00
};