1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

External grunt tasks

- all the grunt tasks are now external
- changed package.json name from project-x to boilerplate
- remove various grunt tasks that weren't being used
-- jshint
-- phplint
-- imagemin (we now use kraken)
- add load-grunt-tasks
- fixed a few indent issues with various grunt tasks
This commit is contained in:
Stephen Bégay
2015-04-03 14:10:51 -04:00
parent 79c1e27a4c
commit 83dbd29a7a
12 changed files with 152 additions and 262 deletions

View File

@@ -4,251 +4,39 @@ module.exports = function(grunt) {
pkg: grunt.file.readJSON('package.json'),
// watch: Run tasks whenever watched files change.
watch : require('./grunt_tasks/watch'),
// sass: Compile Sass to CSS
sass: require('./grunt_tasks/sass'),
// autoprefixer: Parse CSS and add vendor prefixes to CSS rules using values from the Can I Use website
autoprefixer : require('./grunt_tasks/autoprefixer'),
// csscomb: Sort CSS properties in specific order.
csscomb : require('./grunt_tasks/csscomb'),
// cssmin: Compress CSS files
cssmin : require('./grunt_tasks/cssmin'),
// svgstore: Merge svgs from a folder
svgstore: require('./grunt_tasks/svgstore'),
// svgmin: Minify SVG
svgmin : require('./grunt_tasks/cssmin'),
// concat: Concatenate files.
concat: require('./grunt_tasks/concat'),
// autoprefixer: Parse CSS and add vendor prefixes to CSS rules using values from the Can I Use website
autoprefixer: {
build: {
options: {
browsers: ['last 2 versions', '> 1%', 'ie >= 8']
},
files: [
{
src : ['assets/styles/dist/*.css'],
dest : 'assets/styles/dist/',
expand : true,
flatten : true
}
]
}
},
// watch: Run tasks whenever watched files change.
watch: {
concat: {
files: ['assets/scripts/src/**/*.js'],
tasks: ['concat', 'notify:concat']
},
sass: {
files: ['assets/styles/src/**/*.scss'],
tasks: ['sass', 'autoprefixer', 'notify:sass'],
options: {
spawn: false,
livereload: true
}
},
svgstore: {
files: ['assets/images/**/*.svg'],
tasks: ['svgstore', 'notify:svg']
},
tasks: {
files: ['grunt_tasks/*.js'],
options: {
reload: true
}
}
},
// uglify: Minify (javascript)files with UglifyJS
uglify : require('./grunt_tasks/uglify'),
// notify: Automatic Notifications when Grunt tasks fail (or succeed)
notify: {
watch: {
options: {
// title: '<%= pkg.title %>',
message: 'Keeping an eye out, Chief!'
}
},
sass: {
options: {
// title: '<%= pkg.title %>',
message: 'Sass compiled to CSS.'
}
},
concat: {
options: {
// title: '<%= pkg.title %>',
message: 'JavaScript is now concatenated'
}
},
svg: {
options: {
// title: '<%= pkg.title %>',
message: 'SVG is now concatenated'
}
}
},
// csscomb: Sort CSS properties in specific order.
csscomb: {
options: {
config: '.csscomb.json'
},
build: {
expand: true,
cwd: 'assets/styles/src/',
src: ['**/*.scss'],
dest: 'assets/styles/src/'
}
},
// uglify: Minify (javascript)files with UglifyJS
uglify: {
target: {
files: [{
expand: true,
cwd: 'assets/scripts/dist/',
src: '**/*.js',
dest: 'assets/scripts/dist/'
}]
}
},
// cssmin: Compress CSS files
cssmin: {
combine: {
files: [{
expand: true,
cwd: 'assets/styles/dist/',
src: '*.css',
dest: 'assets/styles/dist/'
}]
}
},
// svgmin: Minify SVG
svgmin: {
options: {
plugins: [
{ removeViewBox: false },
{ cleanupIDs: false },
{ convertPathData: false },
{ mergePaths: false },
{ convertShapeToPath: false },
{ cleanupNumericValues: false },
{ convertTransform: false },
{ removeUselessStrokeAndFill: false },
{ removeTitle: true },
{ removeDesc: true }
]
},
dist: {
expand: true,
cwd: 'assets/images/dist/',
src: '*.svg',
dest: 'assets/images/dist/',
ext: '.svg',
extDot: 'first'
}
},
// imagemin: Minify PNG and JPEG images.
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'assets/images/',
src: ['*.{png,jpg,gif}'],
dest: 'assets/images/'
}]
}
},
// jsonlint: Validate JSON files
jsonlint:{
project:{
src:[
'*.json',
'config/*.json',
'config/**/*.json',
'modules/**/config/*.json',
'modules/**/config/**/*.json'
]
},
charcoal:{
src:[
'charcoal/*.json',
'charcoal/core/config/*.json',
'charcoal/core/config/**/*.json',
'charcoal/modules/**/config/*.json',
'charcoal/modules/**/config/**/*.json'
]
}
},
// jshint: Validate javascript files with JSHint
jshint:{
gruntfile:{
src:[
// Self-test
'Gruntfile.js'
]
},
project:{
src:[
'modules/**/assets/scripts/src/*.js',
'modules/**/assets/scripts/src/**/*.js'
]
},
charcoal:{
src:[
'charcoal/core/assets/scripts/src/*.js',
'charcoal/core/assets/scripts/src/**/*.js',
'charcoal/modules/**/assets/scripts/src/*.js',
'charcoal/modules/**/assets/scripts/src/**/*.js'
]
}
},
// phplint: A simple wrapper around the php -l <filename> command.
phplint:{
options: {
swapPath: '/tmp',
phpArgs : {
// add -f for fatal errors
'-lf': null
}
},
project: [
'modules/**/code/*.php',
'modules/**/code/**/*.php',
'modules/**/assets/templates/*.php',
'modules/**/assets/templates/**/*.php'
],
charcoal: [
'charcoal/core/code/*.php',
'charcoal/core/code/**/*.php',
'charcoal/modules/**/code/*.php',
'charcoal/modules/**/code/**/*.php'
]
}
notify : require('./grunt_tasks/notify')
});
// Load tasks
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-svgstore');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-csscomb');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-svgmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-jsonlint');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks("grunt-phplint");
require('load-grunt-tasks')(grunt);
// Register tasks
@@ -266,17 +54,4 @@ module.exports = function(grunt) {
grunt.registerTask('c', [
'csscomb'
]);
grunt.registerTask('wlint', [
// Javasript
'jshint',
'jsonlint',
'concat',
// PHP
'phplint',
// Utilities
'watch'
]);
};

View File

@@ -0,0 +1,15 @@
module.exports = {
build: {
options: {
browsers: ['last 2 versions', '> 1%', 'ie >= 8']
},
files: [
{
src : ['assets/styles/dist/*.css'],
dest : 'assets/styles/dist/',
expand : true,
flatten : true
}
]
}
}

View File

@@ -1,10 +1,8 @@
module.exports = {
main: {
main: {
src: [
'assets/scripts/src/main.js'
],
dest: 'assets/scripts/dist/main.js',
}
}
}

View File

@@ -0,0 +1,11 @@
module.exports = {
options: {
config: '.csscomb.json'
},
build: {
expand: true,
cwd: 'assets/styles/src/',
src: ['**/*.scss'],
dest: 'assets/styles/src/'
}
}

View File

@@ -0,0 +1,10 @@
module.exports = {
combine: {
files: [{
expand: true,
cwd: 'assets/styles/dist/',
src: '*.css',
dest: 'assets/styles/dist/'
}]
}
}

View File

@@ -0,0 +1,26 @@
module.exports = {
watch: {
options: {
// title: '<%= pkg.title %>',
message: 'Keeping an eye out, Chief!'
}
},
sass: {
options: {
// title: '<%= pkg.title %>',
message: 'Sass compiled to CSS.'
}
},
concat: {
options: {
// title: '<%= pkg.title %>',
message: 'JavaScript is now concatenated'
}
},
svg: {
options: {
// title: '<%= pkg.title %>',
message: 'SVG is now concatenated'
}
}
}

View File

@@ -1,12 +1,10 @@
module.exports = {
options: {
sourceMap: false
},
options: {
sourceMap: false
},
dist: {
files: {
'assets/styles/dist/main.css': 'assets/styles/src/main.scss'
}
}
}

View File

@@ -0,0 +1,24 @@
module.exports = {
options: {
plugins: [
{ removeViewBox: false },
{ cleanupIDs: false },
{ convertPathData: false },
{ mergePaths: false },
{ convertShapeToPath: false },
{ cleanupNumericValues: false },
{ convertTransform: false },
{ removeUselessStrokeAndFill: false },
{ removeTitle: true },
{ removeDesc: true }
]
},
dist: {
expand: true,
cwd: 'assets/images/dist/',
src: '*.svg',
dest: 'assets/images/dist/',
ext: '.svg',
extDot: 'first'
}
}

View File

@@ -1,12 +1,10 @@
module.exports = {
options: {
options: {
},
default : {
files: {
'assets/images/dist/svgs.svg': ['assets/images/svgs/*.svg'],
},
},
files: {
'assets/images/dist/svgs.svg': ['assets/images/svgs/*.svg'],
}
}
}

View File

@@ -0,0 +1,10 @@
module.exports = {
target: {
files: [{
expand: true,
cwd: 'assets/scripts/dist/',
src: '**/*.js',
dest: 'assets/scripts/dist/'
}]
}
}

View File

@@ -0,0 +1,24 @@
module.exports = {
javascript: {
files: ['assets/scripts/src/**/*.js'],
tasks: ['concat', 'notify:concat']
},
sass: {
files: ['assets/styles/src/**/*.scss'],
tasks: ['sass', 'autoprefixer', 'notify:sass'],
options: {
spawn: false,
livereload: true
}
},
svg: {
files: ['assets/images/**/*.svg'],
tasks: ['svgstore', 'notify:svg']
},
tasks: {
files: ['grunt_tasks/*.js'],
options: {
reload: true
}
}
}

View File

@@ -1,5 +1,5 @@
{
"name": "projet-x",
"name": "boilerplate",
"version": "1.0.0",
"author": "Locomotive <info@locomotive.ca>",
"contributors": [
@@ -21,6 +21,7 @@
"grunt-phplint": "0.0.0",
"grunt-sass": "0.0.0",
"grunt-svgmin": "0.0.0",
"grunt-svgstore": "0.0.0"
"grunt-svgstore": "0.0.0",
"load-grunt-tasks" : "0.0.0"
}
}