mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
@@ -1,254 +1,28 @@
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
|
||||
function loadConfig(path) {
|
||||
var glob = require('glob');
|
||||
var object = {};
|
||||
var key;
|
||||
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
glob.sync('*', {cwd: path}).forEach(function(option) {
|
||||
key = option.replace(/\.js$/,'');
|
||||
object[key] = require(path + option);
|
||||
});
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
// sass: Compile Sass to CSS
|
||||
sass: require('./grunt_tasks/sass'),
|
||||
|
||||
// svgstore: Merge svgs from a folder
|
||||
svgstore: require('./grunt_tasks/svgstore'),
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 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'
|
||||
]
|
||||
}
|
||||
|
||||
});
|
||||
var config = {
|
||||
pkg: grunt.file.readJSON('package.json')
|
||||
}
|
||||
grunt.loadTasks('grunt_tasks');
|
||||
grunt.util._.extend(config, loadConfig('./grunt_tasks/'));
|
||||
grunt.initConfig(config);
|
||||
|
||||
// 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
|
||||
@@ -267,13 +41,9 @@ module.exports = function(grunt) {
|
||||
'csscomb'
|
||||
]);
|
||||
grunt.registerTask('wlint', [
|
||||
// Javasript
|
||||
'jshint',
|
||||
'jsonlint',
|
||||
'concat',
|
||||
|
||||
// PHP
|
||||
'phplint',
|
||||
'jsonlint',
|
||||
|
||||
// Utilities
|
||||
'watch'
|
||||
|
||||
15
www/modules/boilerplate/grunt_tasks/autoprefixer.js
Normal file
15
www/modules/boilerplate/grunt_tasks/autoprefixer.js
Normal 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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
module.exports = {
|
||||
|
||||
main: {
|
||||
main: {
|
||||
src: [
|
||||
'assets/scripts/src/main.js'
|
||||
],
|
||||
dest: 'assets/scripts/dist/main.js',
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
www/modules/boilerplate/grunt_tasks/csscomb.js
Normal file
11
www/modules/boilerplate/grunt_tasks/csscomb.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
config: '.csscomb.json'
|
||||
},
|
||||
build: {
|
||||
expand: true,
|
||||
cwd: 'assets/styles/src/',
|
||||
src: ['**/*.scss'],
|
||||
dest: 'assets/styles/src/'
|
||||
}
|
||||
}
|
||||
10
www/modules/boilerplate/grunt_tasks/cssmin.js
Normal file
10
www/modules/boilerplate/grunt_tasks/cssmin.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
combine: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'assets/styles/dist/',
|
||||
src: '*.css',
|
||||
dest: 'assets/styles/dist/'
|
||||
}]
|
||||
}
|
||||
}
|
||||
20
www/modules/boilerplate/grunt_tasks/jsonlint.js
Normal file
20
www/modules/boilerplate/grunt_tasks/jsonlint.js
Normal file
@@ -0,0 +1,20 @@
|
||||
module.exports = {
|
||||
project:{
|
||||
src:[
|
||||
'*.json',
|
||||
'../config/*.json',
|
||||
'../config/**/*.json',
|
||||
'config/*.json',
|
||||
'config/**/*.json'
|
||||
]
|
||||
},
|
||||
charcoal:{
|
||||
src:[
|
||||
'../charcoal/*.json',
|
||||
'../charcoal/core/config/*.json',
|
||||
'../charcoal/core/config/**/*.json',
|
||||
'../charcoal/modules/**/config/*.json',
|
||||
'../charcoal/modules/**/config/**/*.json'
|
||||
]
|
||||
}
|
||||
}
|
||||
26
www/modules/boilerplate/grunt_tasks/notify.js
Normal file
26
www/modules/boilerplate/grunt_tasks/notify.js
Normal 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'
|
||||
}
|
||||
}
|
||||
}
|
||||
22
www/modules/boilerplate/grunt_tasks/phplint.js
Normal file
22
www/modules/boilerplate/grunt_tasks/phplint.js
Normal file
@@ -0,0 +1,22 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
swapPath: '/tmp',
|
||||
phpArgs : {
|
||||
// add -f for fatal errors
|
||||
'-lf': null
|
||||
}
|
||||
},
|
||||
|
||||
project: [
|
||||
'code/*.php',
|
||||
'code/**/*.php',
|
||||
'assets/templates/*.php',
|
||||
'assets/templates/**/*.php'
|
||||
],
|
||||
charcoal: [
|
||||
'../charcoal/core/code/*.php',
|
||||
'../charcoal/core/code/**/*.php',
|
||||
'../charcoal/modules/**/code/*.php',
|
||||
'../charcoal/modules/**/code/**/*.php'
|
||||
]
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
module.exports = {
|
||||
|
||||
options: {
|
||||
sourceMap: false
|
||||
},
|
||||
options: {
|
||||
sourceMap: false
|
||||
},
|
||||
dist: {
|
||||
files: {
|
||||
'assets/styles/dist/main.css': 'assets/styles/src/main.scss'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
24
www/modules/boilerplate/grunt_tasks/svgmin.js
Normal file
24
www/modules/boilerplate/grunt_tasks/svgmin.js
Normal 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'
|
||||
}
|
||||
}
|
||||
@@ -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'],
|
||||
}
|
||||
}
|
||||
}
|
||||
10
www/modules/boilerplate/grunt_tasks/uglify.js
Normal file
10
www/modules/boilerplate/grunt_tasks/uglify.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
target: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'assets/scripts/dist/',
|
||||
src: '**/*.js',
|
||||
dest: 'assets/scripts/dist/'
|
||||
}]
|
||||
}
|
||||
}
|
||||
24
www/modules/boilerplate/grunt_tasks/watch.js
Normal file
24
www/modules/boilerplate/grunt_tasks/watch.js
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "projet-x",
|
||||
"name": "boilerplate",
|
||||
"version": "1.0.0",
|
||||
"author": "Locomotive <info@locomotive.ca>",
|
||||
"contributors": [
|
||||
@@ -11,16 +11,16 @@
|
||||
"grunt-autoprefixer": "0.0.0",
|
||||
"grunt-contrib-concat": "0.0.0",
|
||||
"grunt-contrib-cssmin": "0.0.0",
|
||||
"grunt-contrib-imagemin": "0.0.0",
|
||||
"grunt-contrib-jshint": "0.0.0",
|
||||
"grunt-contrib-uglify": "0.0.0",
|
||||
"grunt-contrib-watch": "0.0.0",
|
||||
"grunt-csscomb": "0.0.0",
|
||||
"grunt-jsonlint": "0.0.0",
|
||||
"grunt-notify": "0.0.0",
|
||||
"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",
|
||||
"grunt-phplint": "0.0.0",
|
||||
"grunt-jsonlint": "0.0.0",
|
||||
"glob": "0.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user