mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
Added 'load-grunt-config' plugin
The plugin replaces the custom 'loadConfig()' function with a more robust and extensible solution. It handles 'grunt.initConfig()' and 'load-grunt-tasks'. Changes: - Moved Grunt task configurations into a 'config/' sub-directory to allow room for custom plugins, modules, and tasks to be defined without being included by the config-loader; - Updated '.eslintrc' to better lint module-based JS; - Updated EditorConfig recommendations;
This commit is contained in:
@@ -10,9 +10,6 @@ end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.json,.bowerrc]
|
||||
insert_final_newline = false
|
||||
|
||||
[{.htaccess,.bowerrc,bower.json,package.json,component.json}]
|
||||
[{*.md,.*rc,.*.json,*.yml,.editorconfig,.env,.env.*,.git*,.htaccess,.jshintignore,bower.json,composer.json,package.json}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"ecmaFeatures": {
|
||||
"arrowFunctions": true,
|
||||
"binaryLiterals": true,
|
||||
|
||||
16
.gitignore
vendored
16
.gitignore
vendored
@@ -1,3 +1,15 @@
|
||||
.DS_Store
|
||||
# General
|
||||
# -----------------
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
error_log
|
||||
|
||||
# Package Managers
|
||||
# -----------------
|
||||
|
||||
composer.phar
|
||||
vendor/
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
bower_components/
|
||||
|
||||
80
Gruntfile.js
80
Gruntfile.js
@@ -1,55 +1,35 @@
|
||||
module.exports = function(grunt) {
|
||||
/**
|
||||
* Grunt Task Wrangler
|
||||
*
|
||||
* @copyright Copyright © 2016 Locomotive
|
||||
* @license Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
function loadConfig(path) {
|
||||
var glob = require('glob');
|
||||
var object = {};
|
||||
var key;
|
||||
'use strict';
|
||||
|
||||
glob.sync('*', {cwd: path}).forEach(function(option) {
|
||||
key = option.replace(/\.js$/,'');
|
||||
object[key] = require(path + option);
|
||||
module.exports = function (grunt)
|
||||
{
|
||||
var path = require('path');
|
||||
|
||||
require('load-grunt-config')(grunt, {
|
||||
configPath: path.join(process.cwd(), 'build/grunt/config'),
|
||||
data: {
|
||||
paths: {
|
||||
grunt: 'build/grunt',
|
||||
js: {
|
||||
src: 'assets/scripts',
|
||||
dist: 'www/assets/scripts'
|
||||
},
|
||||
css: {
|
||||
src: 'assets/styles',
|
||||
dist: 'www/assets/styles'
|
||||
},
|
||||
img: {
|
||||
src: 'assets/images',
|
||||
dist: 'www/assets/images'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
var config = {
|
||||
pkg: grunt.file.readJSON('package.json')
|
||||
}
|
||||
|
||||
grunt.loadTasks('build/grunt');
|
||||
grunt.util._.extend(config, loadConfig('./build/grunt/'));
|
||||
grunt.initConfig(config);
|
||||
|
||||
// Load tasks
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
// Register tasks
|
||||
grunt.registerTask('default', ['build']);
|
||||
grunt.registerTask('sync', ['browserSync', 'browserify:dev', 'watch', 'notify:watch']);
|
||||
grunt.registerTask('build', [
|
||||
// CSS
|
||||
'sass',
|
||||
'postcss',
|
||||
'cssmin',
|
||||
// JS
|
||||
'browserify:prod',
|
||||
'uglify',
|
||||
// SVG
|
||||
'svgstore',
|
||||
'svgmin',
|
||||
// Notify
|
||||
'notify:build'
|
||||
]);
|
||||
grunt.registerTask('w', ['browserify:dev', 'watch', 'notify:watch']);
|
||||
grunt.registerTask('c', [
|
||||
'csscomb'
|
||||
]);
|
||||
grunt.registerTask('j', [
|
||||
'eslint'
|
||||
]);
|
||||
grunt.registerTask('p', [
|
||||
'phplint'
|
||||
]);
|
||||
|
||||
};
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
module.exports = {
|
||||
dev: {
|
||||
bsFiles: {
|
||||
src : [
|
||||
'www/assets/styles/**/*.css'
|
||||
,'www/assets/scripts/**/*.js'
|
||||
,'www/assets/images/**/*.svg'
|
||||
,'www/**/*.php'
|
||||
]
|
||||
},
|
||||
options: {
|
||||
proxy: "localhost",
|
||||
port: 3000,
|
||||
watchTask: true,
|
||||
notify: false
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
module.exports = {
|
||||
dev: {
|
||||
options: {
|
||||
transform: [['babelify', { presets: ['es2015'] }]],
|
||||
watch : true, // use watchify for incremental builds!
|
||||
browserifyOptions : {
|
||||
debug : true // source mapping
|
||||
}
|
||||
},
|
||||
files: {
|
||||
'www/assets/scripts/app.js': [
|
||||
'assets/scripts/**/*.js',
|
||||
'!assets/scripts/vendors/*.js'
|
||||
]
|
||||
}
|
||||
},
|
||||
prod: {
|
||||
options: {
|
||||
transform: [['babelify', { presets: ['es2015'] }]],
|
||||
browserifyOptions: { debug: false },
|
||||
exclude: ''
|
||||
},
|
||||
files: {
|
||||
'www/assets/scripts/app.js': [
|
||||
'assets/scripts/**/*.js',
|
||||
'!assets/scripts/vendors/*.js'
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,8 +0,0 @@
|
||||
module.exports = {
|
||||
vendors: {
|
||||
src: [
|
||||
'assets/scripts/vendors/*.js'
|
||||
],
|
||||
dest: 'www/assets/scripts/vendors.js'
|
||||
}
|
||||
};
|
||||
41
build/grunt/config/aliases.json
Normal file
41
build/grunt/config/aliases.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"default": [
|
||||
"build"
|
||||
],
|
||||
|
||||
"sync": [
|
||||
"browserSync",
|
||||
"browserify:dev",
|
||||
"watch",
|
||||
"notify:watch"
|
||||
],
|
||||
|
||||
"build": [
|
||||
"sass",
|
||||
"postcss",
|
||||
"cssmin",
|
||||
"browserify:prod",
|
||||
"uglify",
|
||||
"svgstore",
|
||||
"svgmin",
|
||||
"notify:build"
|
||||
],
|
||||
|
||||
"w": [
|
||||
"browserify:dev",
|
||||
"watch",
|
||||
"notify:watch"
|
||||
],
|
||||
|
||||
"c": [
|
||||
"csscomb"
|
||||
],
|
||||
|
||||
"j": [
|
||||
"eslint"
|
||||
],
|
||||
|
||||
"p": [
|
||||
"phplint"
|
||||
]
|
||||
}
|
||||
18
build/grunt/config/browserSync.js
Normal file
18
build/grunt/config/browserSync.js
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
proxy : 'localhost',
|
||||
port : 3000,
|
||||
watchTask : true,
|
||||
notify : false
|
||||
},
|
||||
dev: {
|
||||
bsFiles: {
|
||||
src : [
|
||||
'<%= paths.css.dist %>/**/*.css',
|
||||
'<%= paths.js.dist %>/**/*.js',
|
||||
'<%= paths.img.dist %>/**/*.svg',
|
||||
'**/*.php'
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
34
build/grunt/config/browserify.js
Normal file
34
build/grunt/config/browserify.js
Normal file
@@ -0,0 +1,34 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
browserifyOptions: {
|
||||
debug: false
|
||||
},
|
||||
exclude: "",
|
||||
transform: [
|
||||
[ 'babelify', { presets: [ 'es2015' ] } ]
|
||||
]
|
||||
},
|
||||
dev: {
|
||||
options: {
|
||||
browserifyOptions: {
|
||||
debug: true
|
||||
},
|
||||
watch: true
|
||||
},
|
||||
src: [
|
||||
'<%= paths.js.src %>/**/*.js',
|
||||
'!<%= paths.js.src %>/vendors/**/*.js'
|
||||
],
|
||||
dest: '<%= paths.js.dist %>/app.js'
|
||||
},
|
||||
prod: {
|
||||
options: {
|
||||
banner: '/*! <%= package.title %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n'
|
||||
},
|
||||
src: [
|
||||
'<%= paths.js.src %>/**/*.js',
|
||||
'!<%= paths.js.src %>/vendors/**/*.js'
|
||||
],
|
||||
dest: '<%= paths.js.dist %>/app.js'
|
||||
}
|
||||
};
|
||||
12
build/grunt/config/concat.js
Normal file
12
build/grunt/config/concat.js
Normal file
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
stripBanners: true
|
||||
},
|
||||
prod: {
|
||||
options: {
|
||||
banner: '/*! Dependencies for <%= package.title %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n'
|
||||
},
|
||||
src : [ '<%= paths.js.src %>/vendors/**/*.js' ],
|
||||
dest : '<%= paths.js.dist %>/vendors.js'
|
||||
}
|
||||
};
|
||||
15
build/grunt/config/csscomb.js
Normal file
15
build/grunt/config/csscomb.js
Normal file
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
config: '.csscomb.json'
|
||||
},
|
||||
dev: {
|
||||
files: [
|
||||
{
|
||||
expand : true,
|
||||
cwd : '<%= paths.css.src %>',
|
||||
src : [ '**/*.scss', '!base/_fonts.scss' ],
|
||||
dest : '<%= paths.css.src %>'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
13
build/grunt/config/cssmin.js
Normal file
13
build/grunt/config/cssmin.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
options: {},
|
||||
prod: {
|
||||
files: [
|
||||
{
|
||||
expand : true,
|
||||
cwd : '<%= paths.css.dist %>',
|
||||
src : [ '**/*.css', '!**/*.min.css' ],
|
||||
dest : '<%= paths.css.dist %>'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
11
build/grunt/config/eslint.js
Normal file
11
build/grunt/config/eslint.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
quiet : false,
|
||||
format : require('eslint-tap'),
|
||||
configFile : '.eslintrc'
|
||||
},
|
||||
dev: [
|
||||
'<%= paths.js.src %>/**/*.js',
|
||||
'!<%= paths.js.src %>/vendors/**/*.js'
|
||||
]
|
||||
};
|
||||
@@ -1,31 +1,35 @@
|
||||
module.exports = {
|
||||
notify_hooks: {
|
||||
options: {
|
||||
enabled : true,
|
||||
success : true,
|
||||
duration : 3,
|
||||
title : '<%= package.name %>',
|
||||
max_jshint_notifications : 5
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
options: {
|
||||
// title: '<%= pkg.title %>',
|
||||
message: 'Keeping an eye out, Chief!'
|
||||
}
|
||||
},
|
||||
build: {
|
||||
options: {
|
||||
// title: '<%= pkg.title %>',
|
||||
message: 'Everything is ready to go!'
|
||||
}
|
||||
},
|
||||
sass: {
|
||||
options: {
|
||||
// title: '<%= pkg.title %>',
|
||||
message: 'CSS is compiled'
|
||||
}
|
||||
},
|
||||
javascript: {
|
||||
options: {
|
||||
// title: '<%= pkg.title %>',
|
||||
message: 'JavaScript is compiled'
|
||||
}
|
||||
},
|
||||
svg: {
|
||||
options: {
|
||||
// title: '<%= pkg.title %>',
|
||||
message: 'SVG is concatenated'
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
swapPath: '/tmp',
|
||||
swapPath : '/tmp',
|
||||
phpArgs : {
|
||||
// add -f for fatal errors
|
||||
'-lf': null
|
||||
}
|
||||
},
|
||||
|
||||
project: [
|
||||
dev: [
|
||||
'**/*.php'
|
||||
]
|
||||
}
|
||||
;
|
||||
};
|
||||
27
build/grunt/config/postcss.js
Normal file
27
build/grunt/config/postcss.js
Normal file
@@ -0,0 +1,27 @@
|
||||
module.exports = function (grunt, options)
|
||||
{
|
||||
return {
|
||||
options: {
|
||||
map: false,
|
||||
processors: [
|
||||
require('autoprefixer')({
|
||||
browsers: [ 'last 2 versions', '> 1%', 'ie >= 9' ]
|
||||
}),
|
||||
require('postcss-banner')({
|
||||
banner: grunt.template.process('! <%= package.title %> - <%= grunt.template.today("yyyy-mm-dd") %> ', { data: options })
|
||||
})
|
||||
]
|
||||
},
|
||||
prod: {
|
||||
files: [
|
||||
{
|
||||
expand : true,
|
||||
flatten : true,
|
||||
cwd : '<%= paths.css.dist %>',
|
||||
src : [ '**/*.css', '!**/*.min.css' ],
|
||||
dest : '<%= paths.css.dist %>'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
17
build/grunt/config/sass.js
Normal file
17
build/grunt/config/sass.js
Normal file
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
sourceMap : false,
|
||||
outputStyle : 'expanded'
|
||||
},
|
||||
prod: {
|
||||
files: [
|
||||
{
|
||||
expand : true,
|
||||
cwd : '<%= paths.css.src %>',
|
||||
src : [ '**/*.scss' ],
|
||||
dest : '<%= paths.css.dist %>',
|
||||
ext : '.css'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -14,11 +14,9 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
dist: {
|
||||
expand: true,
|
||||
cwd: 'www/assets/images/',
|
||||
src: '*.svg',
|
||||
dest: 'www/assets/images/',
|
||||
ext: '.svg',
|
||||
extDot: 'first'
|
||||
expand : true,
|
||||
cwd : '<%= paths.img.dist %>',
|
||||
src : '*.svg',
|
||||
dest : '<%= paths.img.dist %>'
|
||||
}
|
||||
};
|
||||
8
build/grunt/config/svgstore.js
Normal file
8
build/grunt/config/svgstore.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
options: {},
|
||||
prod: {
|
||||
files: {
|
||||
'<%= paths.img.dist %>/sprite.svg': [ '<%= paths.img.src %>/sprite/*.svg' ]
|
||||
}
|
||||
}
|
||||
};
|
||||
13
build/grunt/config/uglify.js
Normal file
13
build/grunt/config/uglify.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
options: {},
|
||||
prod: {
|
||||
files: [
|
||||
{
|
||||
expand : true,
|
||||
cwd : '<%= paths.js.dist %>',
|
||||
src : [ '**/*.js', '!**/*.min.js' ],
|
||||
dest : '<%= paths.js.dist %>'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
27
build/grunt/config/watch.js
Normal file
27
build/grunt/config/watch.js
Normal file
@@ -0,0 +1,27 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
spawn: false,
|
||||
livereload: false
|
||||
},
|
||||
javascript_vendors: {
|
||||
files: [ '<%= paths.js.src %>/vendors/**/*.js' ],
|
||||
tasks: [ 'concat:vendors', 'notify:javascript' ]
|
||||
},
|
||||
sass: {
|
||||
files: [ '<%= paths.css.src %>/**/*.scss' ],
|
||||
tasks: [ 'sass', 'postcss', 'notify:sass' ]
|
||||
},
|
||||
svg: {
|
||||
files: [ '<%= paths.img.src %>/**/*.svg' ],
|
||||
tasks: [ 'svgstore', 'notify:svg' ]
|
||||
},
|
||||
tasks: {
|
||||
options: {
|
||||
reload: true
|
||||
},
|
||||
files: [
|
||||
'Gruntfile.js',
|
||||
'<%= paths.grunt %>/**/*'
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
config: '.csscomb.json'
|
||||
},
|
||||
build: {
|
||||
expand: true,
|
||||
cwd: 'assets/styles/',
|
||||
src: ['**/*.scss', '!base/_fonts.scss'],
|
||||
dest: 'assets/styles/'
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
combine: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'www/assets/styles/',
|
||||
src: '*.css',
|
||||
dest: 'www/assets/styles/'
|
||||
}]
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
format: require('eslint-tap'),
|
||||
configFile: '.eslintrc'
|
||||
},
|
||||
target: [
|
||||
'assets/scripts/**/*.js',
|
||||
'!assets/scripts/vendors/*.js'
|
||||
],
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
module.exports = {
|
||||
postcss: {
|
||||
options: {
|
||||
processors: [
|
||||
require('autoprefixer')({
|
||||
browsers: ['last 2 versions', '> 1%', 'ie >= 9']
|
||||
}),
|
||||
]
|
||||
},
|
||||
files: [
|
||||
{
|
||||
src : ['www/assets/styles/*.css'],
|
||||
dest : 'www/assets/styles/',
|
||||
expand : true,
|
||||
flatten : true
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
sourceMap: false
|
||||
},
|
||||
dist: {
|
||||
files: {
|
||||
'www/assets/styles/main.css': 'assets/styles/main.scss'
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
options: {
|
||||
|
||||
},
|
||||
default : {
|
||||
files: {
|
||||
'www/assets/images/sprite.svg': ['assets/images/sprite/*.svg'],
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
module.exports = {
|
||||
target: {
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: 'www/assets/scripts/',
|
||||
src: '**/*.js',
|
||||
dest: 'www/assets/scripts/'
|
||||
}]
|
||||
}
|
||||
};
|
||||
@@ -1,26 +0,0 @@
|
||||
module.exports = {
|
||||
javascript_vendors: {
|
||||
files: [
|
||||
'assets/scripts/vendors/*.js'
|
||||
],
|
||||
tasks: ['concat:vendors', 'notify:javascript']
|
||||
},
|
||||
sass: {
|
||||
files: ['assets/styles/**/*.scss'],
|
||||
tasks: ['sass', 'postcss', 'notify:sass'],
|
||||
options: {
|
||||
spawn: false,
|
||||
livereload: true
|
||||
}
|
||||
},
|
||||
svg: {
|
||||
files: ['assets/images/**/*.svg'],
|
||||
tasks: ['svgstore', 'notify:svg']
|
||||
},
|
||||
tasks: {
|
||||
files: ['build/grunt/*.js'],
|
||||
options: {
|
||||
reload: true
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
{
|
||||
"name": "boilerplate",
|
||||
"private": true,
|
||||
"name": "@locomotivemtl/boilerplate",
|
||||
"title": "Locomotive Boilerplate",
|
||||
"version": "1.0.0",
|
||||
"author": "Locomotive <info@locomotive.ca>",
|
||||
"devDependencies": {
|
||||
@@ -12,7 +14,7 @@
|
||||
"grunt-browser-sync": "2.2.0",
|
||||
"grunt-browserify": "4.0.1",
|
||||
"grunt-contrib-concat": "1.0.0",
|
||||
"grunt-contrib-cssmin": "1.0.0",
|
||||
"grunt-contrib-cssmin": "^1.0.1",
|
||||
"grunt-contrib-uglify": "1.0.0",
|
||||
"grunt-contrib-watch": "0.6.1",
|
||||
"grunt-csscomb": "3.1.0",
|
||||
@@ -23,6 +25,7 @@
|
||||
"grunt-sass": "1.1.0",
|
||||
"grunt-svgmin": "3.1.2",
|
||||
"grunt-svgstore": "1.0.0",
|
||||
"load-grunt-tasks": "3.4.1"
|
||||
"load-grunt-config": "^0.19.1",
|
||||
"postcss-banner": "^1.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user