3c0722ef by bootflat

modify package.json and Gruntfile.js

1 parent 2d70096e
1 module.exports = function(grunt) { 1 module.exports = function(grunt) {
2 2
3 grunt.util.linefeed = '\n';
4
5 RegExp.quote = function (string) {
6 return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
7 };
8
3 grunt.initConfig({ 9 grunt.initConfig({
10 pkg: grunt.file.readJSON('package.json'),
11
12 meta: {
13 defaultPath: 'bootflat'
14 },
15
16 banner: '/*\n * <%= pkg.name %> <%= pkg.version %>\n' +
17 ' *\n' +
18 ' * Description: <%= pkg.description %>\n' +
19 ' *\n' +
20 ' * Homepage: <%= pkg.homepage %>\n' +
21 ' *\n' +
22 ' * By @<%= pkg.author %>\n' +
23 ' *\n' +
24 ' * Last modify time: <%= grunt.template.today("yyyy-mm-dd") %>\n' +
25 ' *\n' +
26 ' * Licensed under the MIT license. Please see LICENSE for more information.\n' +
27 ' *\n' +
28 ' * Copyright 2013 FLATHEMES.\n' +
29 ' *\n' +
30 ' */\n',
31
32 clean: {
33 dist: ['<%= meta.defaultPath %>/css/']
34 },
4 uglify: { 35 uglify: {
5 options: { 36 options: {
6 banner: '/*\n * <%= pkg.name %> <%= pkg.version %>\n' + 37 banner: '<%= banner %>',
7 ' *\n' +
8 ' * Description: <%= pkg.description %>\n' +
9 ' *\n' +
10 ' * Homepage: <%= pkg.homepage %>\n' +
11 ' *\n' +
12 ' * By @<%= pkg.author %>\n' +
13 ' *\n' +
14 ' * Last modify time: <%= grunt.template.today("yyyy-mm-dd") %>\n' +
15 ' *\n' +
16 ' * Licensed under the MIT license. Please see LICENSE for more information.\n' +
17 ' *\n' +
18 ' * Copyright 2013 FLATHEMES.\n' +
19 ' *\n' +
20 ' */\n',
21 sourceMap: true, 38 sourceMap: true,
22 sourceMapIncludeSources: true 39 sourceMapIncludeSources: true
23 }, 40 },
...@@ -26,76 +43,100 @@ module.exports = function(grunt) { ...@@ -26,76 +43,100 @@ module.exports = function(grunt) {
26 'js/site.min.js': [ 43 'js/site.min.js': [
27 'js/jquery-1.10.1.min.js', 44 'js/jquery-1.10.1.min.js',
28 'js/bootstrap.min.js', 45 'js/bootstrap.min.js',
29 'bootflat/js/icheck.min.js', 46 '<%= meta.defaultPath %>/js/icheck.min.js',
30 'js/application.js' 47 'js/application.js'
31 ] 48 ]
32 } 49 }
33 } 50 }
34 }, 51 },
52 csscomb: {
53 options: {
54 config: '<%= meta.defaultPath %>/scss/.csscomb.json'
55 },
56 dist: {
57 files: {
58 '<%= meta.defaultPath %>/css/<%= pkg.name %>.css': 'bootflat/css/<%= pkg.name %>.css'
59 }
60 }
61 },
35 cssmin: { 62 cssmin: {
36 options: { 63 options: {
37 keepSpecialComments: 0, 64 keepSpecialComments: 0,
38 banner: '/*\n * <%= pkg.name %> <%= pkg.version %>\n' + 65 banner: '<%= banner %>',
39 ' *\n' +
40 ' * Description: <%= pkg.description %>\n' +
41 ' *\n' +
42 ' * Homepage: <%= pkg.homepage %>\n' +
43 ' *\n' +
44 ' * By @<%= pkg.author %>\n' +
45 ' *\n' +
46 ' * Last modify time: <%= grunt.template.today("yyyy-mm-dd") %>\n' +
47 ' *\n' +
48 ' * Licensed under the MIT license. Please see LICENSE for more information.\n' +
49 ' *\n' +
50 ' * Copyright 2013 FLATHEMES.\n' +
51 ' *\n' +
52 ' */\n',
53 }, 66 },
54 dist: { 67 dist: {
55 files: { 68 files: {
56 'css/site.min.css': [ 69 'css/site.min.css': [
57 'css/bootstrap.min.css', 70 'css/bootstrap.min.css',
58 'bootflat/css/bootflat.css', 71 '<%= meta.defaultPath %>/css/<%= pkg.name %>.css',
59 'css/site.css' 72 'css/site.css'
60 ], 73 ],
61 'bootflat/css/bootflat.min.css': 'bootflat/css/bootflat.css' 74 '<%= meta.defaultPath %>/css/<%= pkg.name %>.min.css': '<%= meta.defaultPath %>/css/<%= pkg.name %>.css'
62 } 75 }
63 } 76 }
64 }, 77 },
65 sass: { 78 sass: {
66 dist: { 79 dist: {
67 files: { 80 files: {
68 'bootflat/css/bootflat.css': 'bootflat/scss/bootflat.scss' 81 '<%= meta.defaultPath %>/css/<%= pkg.name %>.css': '<%= meta.defaultPath %>/scss/<%= pkg.name %>.scss'
69 }, 82 },
70 options: { 83 options: {
71 banner: '/*\n * <%= pkg.name %> <%= pkg.version %>\n' + 84 banner: '<%= banner %>',
72 ' *\n' +
73 ' * Description: <%= pkg.description %>\n' +
74 ' *\n' +
75 ' * Homepage: <%= pkg.homepage %>\n' +
76 ' *\n' +
77 ' * By @<%= pkg.author %>\n' +
78 ' *\n' +
79 ' * Last modify time: <%= grunt.template.today("yyyy-mm-dd") %>\n' +
80 ' *\n' +
81 ' * Licensed under the MIT license. Please see LICENSE for more information.\n' +
82 ' *\n' +
83 ' * Copyright 2013 FLATHEMES.\n' +
84 ' *\n' +
85 ' */\n',
86 style: 'expanded', 85 style: 'expanded',
87 sourcemap: 'true' 86 sourcemap: 'true'
88 } 87 }
89 } 88 }
90 }, 89 },
91 pkg: grunt.file.readJSON('package.json') 90 csslint: {
91 options: {
92 csslintrc: '<%= meta.defaultPath %>/scss/.csslintrc'
93 },
94 src: [
95 '<%= meta.defaultPath %>/css/<%= pkg.name %>.css'
96 ]
97 },
98 validation: {
99 options: {
100 charset: 'utf-8',
101 doctype: 'HTML5',
102 failHard: true,
103 reset: true,
104 relaxerror: [
105 'Bad value apple-mobile-web-app-title for attribute name on element meta: Keyword apple-mobile-web-app-title is not registered.',
106 'Bad value apple-mobile-web-app-status-bar-style for attribute name on element meta: Keyword apple-mobile-web-app-status-bar-style is not registered.',
107 'Bad value X-UA-Compatible for attribute http-equiv on element meta.',
108 'Attribute ontouchstart not allowed on element body at this point.'
109 ]
110 },
111 files: {
112 src: '*.html'
113 }
114 },
115 sed: {
116 versionNumber: {
117 pattern: (function () {
118 var old = grunt.option('oldver');
119 return old ? RegExp.quote(old) : old;
120 })(),
121 replacement: grunt.option('newver'),
122 recursive: true
123 }
124 }
125
92 }); 126 });
93 127
94 require('load-grunt-tasks')(grunt); 128 require('load-grunt-tasks')(grunt);
129 require('time-grunt')(grunt);
130
131 grunt.registerTask('task-css', ['sass', 'csscomb', 'cssmin']);
132 grunt.registerTask('task-js', ['uglify']);
133 grunt.registerTask('task', ['clean', 'task-css', 'task-js']);
134 grunt.registerTask('build', ['task']);
135 grunt.registerTask('default', ['task']);
136 grunt.registerTask('test', ['task', 'csslint', 'validation']);
95 137
96 grunt.registerTask('default', [ 138 // Version numbering task.
97 'sass', 139 // grunt change-version-number --oldver=A.B.C --newver=X.Y.Z
98 'cssmin', 140 // This can be overzealous, so its changes should always be manually reviewed!
99 'uglify' 141 grunt.registerTask('change-version-number', 'sed');
100 ]);
101 }; 142 };
......
...@@ -22,9 +22,15 @@ ...@@ -22,9 +22,15 @@
22 }, 22 },
23 "devDependencies": { 23 "devDependencies": {
24 "grunt": "~0.4.4", 24 "grunt": "~0.4.4",
25 "grunt-contrib-clean": "~0.5.0",
26 "grunt-contrib-csslint": "~0.2.0",
25 "grunt-contrib-cssmin": "~0.9.0", 27 "grunt-contrib-cssmin": "~0.9.0",
26 "grunt-contrib-uglify": "~0.4.0", 28 "grunt-contrib-uglify": "~0.4.0",
27 "grunt-contrib-sass": "~0.7.3", 29 "grunt-contrib-sass": "~0.7.3",
28 "load-grunt-tasks": "~0.2.0" 30 "grunt-csscomb": "~2.0.1",
31 "grunt-html-validation": "~0.1.15",
32 "grunt-sed": "~0.1.1",
33 "load-grunt-tasks": "~0.4.0",
34 "time-grunt": "~0.3.1"
29 } 35 }
30 } 36 }
......