|
1 | | -module.exports = function(grunt) { |
| 1 | +module.exports = function (grunt) { |
2 | 2 |
|
3 | | - var path = require('path'); |
| 3 | + var path = require('path'); |
4 | 4 |
|
5 | | - // Project configuration. |
6 | | - grunt.initConfig({ |
7 | | - pkg: grunt.file.readJSON('package.json'), |
8 | | - concat: { |
9 | | - options: { |
10 | | - stripBanners: true, |
11 | | - banner: '/* \n * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy") %> \n * \n * <%= pkg.author %>, and the web community.\n * Licensed under the <%= pkg.license %> license. \n * \n * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. \n *\n */\n\n', |
12 | | - }, |
13 | | - patternlab: { |
14 | | - src: './builder/patternlab.js', |
15 | | - dest: './builder/patternlab.js' |
16 | | - }, |
17 | | - object_factory: { |
18 | | - src: './builder/object_factory.js', |
19 | | - dest: './builder/object_factory.js' |
20 | | - }, |
21 | | - lineage: { |
22 | | - src: './builder/lineage_hunter.js', |
23 | | - dest: './builder/lineage_hunter.js' |
24 | | - }, |
25 | | - media_hunter: { |
26 | | - src: './builder/media_hunter.js', |
27 | | - dest: './builder/media_hunter.js' |
28 | | - }, |
29 | | - patternlab_grunt: { |
30 | | - src: './builder/patternlab_grunt.js', |
31 | | - dest: './builder/patternlab_grunt.js' |
32 | | - }, |
33 | | - patternlab_gulp: { |
34 | | - src: './builder/patternlab_gulp.js', |
35 | | - dest: './builder/patternlab_gulp.js' |
36 | | - }, |
37 | | - parameter_hunter: { |
38 | | - src: './builder/parameter_hunter.js', |
39 | | - dest: './builder/parameter_hunter.js' |
40 | | - }, |
41 | | - pattern_exporter: { |
42 | | - src: './builder/pattern_exporter.js', |
43 | | - dest: './builder/pattern_exporter.js' |
44 | | - }, |
45 | | - pattern_assembler: { |
46 | | - src: './builder/pattern_assembler.js', |
47 | | - dest: './builder/pattern_assembler.js' |
48 | | - }, |
49 | | - pseudopattern_hunter: { |
50 | | - src: './builder/pseudopattern_hunter.js', |
51 | | - dest: './builder/pseudopattern_hunter.js' |
52 | | - }, |
53 | | - list_item_hunter: { |
54 | | - src: './builder/list_item_hunter.js', |
55 | | - dest: './builder/list_item_hunter.js' |
56 | | - }, |
57 | | - style_modifier_hunter: { |
58 | | - src: './builder/style_modifier_hunter.js', |
59 | | - dest: './builder/style_modifier_hunter.js' |
60 | | - } |
61 | | - }, |
62 | | - copy: { |
63 | | - main: { |
64 | | - files: [ |
65 | | - { expand: true, cwd: path.resolve(paths().source.js), src: '*.js', dest: path.resolve(paths().public.js) }, |
66 | | - { expand: true, cwd: path.resolve(paths().source.css), src: '*.css', dest: path.resolve(paths().public.css) }, |
67 | | - { expand: true, cwd: path.resolve(paths().source.images), src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: path.resolve(paths().public.images) }, |
68 | | - { expand: true, cwd: path.resolve(paths().source.fonts), src: '*', dest: path.resolve(paths().public.fonts) }, |
69 | | - { expand: true, cwd: path.resolve(paths().source.data), src: 'annotations.js', dest: path.resolve(paths().public.data) } |
70 | | - ] |
71 | | - }, |
72 | | - styleguide: { |
73 | | - files: [ |
74 | | - { expand: true, cwd: path.resolve(paths().source.styleguide), src: ['*.*', '**/*.*'], dest: path.resolve(paths().public.styleguide) } |
75 | | - ] |
76 | | - } |
77 | | - }, |
78 | | - watch: { |
79 | | - all: { |
80 | | - files: [ |
81 | | - path.resolve(paths().source.css + '**/*.css'), |
82 | | - path.resolve(paths().source.styleguide + 'css/*.css'), |
83 | | - path.resolve(paths().source.patterns + '**/*.mustache'), |
84 | | - path.resolve(paths().source.patterns + '**/*.json'), |
85 | | - path.resolve(paths().source.fonts + '/*'), |
86 | | - path.resolve(paths().source.images + '/*'), |
87 | | - path.resolve(paths().source.data + '*.json') |
88 | | - ], |
89 | | - tasks: ['default', 'bsReload:css'] |
90 | | - } |
91 | | - }, |
92 | | - nodeunit: { |
93 | | - all: ['test/*_tests.js'] |
94 | | - }, |
95 | | - browserSync: { |
96 | | - dev: { |
97 | | - options: { |
98 | | - server: path.resolve(paths().public.root), |
99 | | - watchTask: true, |
100 | | - watchOptions: { |
101 | | - ignoreInitial: true, |
102 | | - ignored: '*.html' |
103 | | - }, |
104 | | - snippetOptions: { |
105 | | - // Ignore all HTML files within the templates folder |
106 | | - blacklist: ['/index.html', '/'] |
107 | | - }, |
108 | | - plugins: [ |
109 | | - { |
110 | | - module: 'bs-html-injector', |
111 | | - options: { |
112 | | - files: [path.resolve(paths().public.root + '/index.html'), path.resolve(paths().public.styleguide + '/styleguide.html')] |
113 | | - } |
114 | | - } |
115 | | - ], |
116 | | - notify: { |
117 | | - styles: [ |
118 | | - 'display: none', |
119 | | - 'padding: 15px', |
120 | | - 'font-family: sans-serif', |
121 | | - 'position: fixed', |
122 | | - 'font-size: 1em', |
123 | | - 'z-index: 9999', |
124 | | - 'bottom: 0px', |
125 | | - 'right: 0px', |
126 | | - 'border-top-left-radius: 5px', |
127 | | - 'background-color: #1B2032', |
128 | | - 'opacity: 0.4', |
129 | | - 'margin: 0', |
130 | | - 'color: white', |
131 | | - 'text-align: center' |
132 | | - ] |
133 | | - } |
134 | | - } |
135 | | - } |
136 | | - }, |
137 | | - bsReload: { |
138 | | - css: path.resolve(paths().public.root + '**/*.css') |
139 | | - } |
140 | | - }); |
| 5 | + function paths() { |
| 6 | + return require('./config.json').paths; |
| 7 | + } |
141 | 8 |
|
142 | | - function paths () { |
143 | | - return require('./config.json').paths; |
144 | | - } |
| 9 | + // Project configuration. |
| 10 | + grunt.initConfig({ |
| 11 | + pkg: grunt.file.readJSON('package.json'), |
| 12 | + concat: { |
| 13 | + options: { |
| 14 | + stripBanners: true, |
| 15 | + banner: '/* \n * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy") %> \n * \n * <%= pkg.author %>, and the web community.\n * Licensed under the <%= pkg.license %> license. \n * \n * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. \n *\n */\n\n' |
| 16 | + }, |
| 17 | + patternlab: { |
| 18 | + src: './builder/patternlab.js', |
| 19 | + dest: './builder/patternlab.js' |
| 20 | + }, |
| 21 | + object_factory: { |
| 22 | + src: './builder/object_factory.js', |
| 23 | + dest: './builder/object_factory.js' |
| 24 | + }, |
| 25 | + lineage: { |
| 26 | + src: './builder/lineage_hunter.js', |
| 27 | + dest: './builder/lineage_hunter.js' |
| 28 | + }, |
| 29 | + media_hunter: { |
| 30 | + src: './builder/media_hunter.js', |
| 31 | + dest: './builder/media_hunter.js' |
| 32 | + }, |
| 33 | + patternlab_grunt: { |
| 34 | + src: './builder/patternlab_grunt.js', |
| 35 | + dest: './builder/patternlab_grunt.js' |
| 36 | + }, |
| 37 | + patternlab_gulp: { |
| 38 | + src: './builder/patternlab_gulp.js', |
| 39 | + dest: './builder/patternlab_gulp.js' |
| 40 | + }, |
| 41 | + parameter_hunter: { |
| 42 | + src: './builder/parameter_hunter.js', |
| 43 | + dest: './builder/parameter_hunter.js' |
| 44 | + }, |
| 45 | + pattern_exporter: { |
| 46 | + src: './builder/pattern_exporter.js', |
| 47 | + dest: './builder/pattern_exporter.js' |
| 48 | + }, |
| 49 | + pattern_assembler: { |
| 50 | + src: './builder/pattern_assembler.js', |
| 51 | + dest: './builder/pattern_assembler.js' |
| 52 | + }, |
| 53 | + pseudopattern_hunter: { |
| 54 | + src: './builder/pseudopattern_hunter.js', |
| 55 | + dest: './builder/pseudopattern_hunter.js' |
| 56 | + }, |
| 57 | + list_item_hunter: { |
| 58 | + src: './builder/list_item_hunter.js', |
| 59 | + dest: './builder/list_item_hunter.js' |
| 60 | + }, |
| 61 | + style_modifier_hunter: { |
| 62 | + src: './builder/style_modifier_hunter.js', |
| 63 | + dest: './builder/style_modifier_hunter.js' |
| 64 | + } |
| 65 | + }, |
| 66 | + copy: { |
| 67 | + main: { |
| 68 | + files: [ |
| 69 | + { expand: true, cwd: path.resolve(paths().source.js), src: '*.js', dest: path.resolve(paths().public.js) }, |
| 70 | + { expand: true, cwd: path.resolve(paths().source.css), src: '*.css', dest: path.resolve(paths().public.css) }, |
| 71 | + { expand: true, cwd: path.resolve(paths().source.images), src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: path.resolve(paths().public.images) }, |
| 72 | + { expand: true, cwd: path.resolve(paths().source.fonts), src: '*', dest: path.resolve(paths().public.fonts) }, |
| 73 | + { expand: true, cwd: path.resolve(paths().source.data), src: 'annotations.js', dest: path.resolve(paths().public.data) } |
| 74 | + ] |
| 75 | + }, |
| 76 | + styleguide: { |
| 77 | + files: [ |
| 78 | + { expand: true, cwd: path.resolve(paths().source.styleguide), src: ['*.*', '**/*.*'], dest: path.resolve(paths().public.styleguide) } |
| 79 | + ] |
| 80 | + } |
| 81 | + }, |
| 82 | + watch: { |
| 83 | + all: { |
| 84 | + files: [ |
| 85 | + path.resolve(paths().source.css + '**/*.css'), |
| 86 | + path.resolve(paths().source.styleguide + 'css/*.css'), |
| 87 | + path.resolve(paths().source.patterns + '**/*.mustache'), |
| 88 | + path.resolve(paths().source.patterns + '**/*.json'), |
| 89 | + path.resolve(paths().source.fonts + '/*'), |
| 90 | + path.resolve(paths().source.images + '/*'), |
| 91 | + path.resolve(paths().source.data + '*.json') |
| 92 | + ], |
| 93 | + tasks: ['default', 'bsReload:css'] |
| 94 | + } |
| 95 | + }, |
| 96 | + nodeunit: { |
| 97 | + all: ['test/*_tests.js'] |
| 98 | + }, |
| 99 | + browserSync: { |
| 100 | + dev: { |
| 101 | + options: { |
| 102 | + server: path.resolve(paths().public.root), |
| 103 | + watchTask: true, |
| 104 | + watchOptions: { |
| 105 | + ignoreInitial: true, |
| 106 | + ignored: '*.html' |
| 107 | + }, |
| 108 | + snippetOptions: { |
| 109 | + // Ignore all HTML files within the templates folder |
| 110 | + blacklist: ['/index.html', '/'] |
| 111 | + }, |
| 112 | + plugins: [ |
| 113 | + { |
| 114 | + module: 'bs-html-injector', |
| 115 | + options: { |
| 116 | + files: [path.resolve(paths().public.root + '/index.html'), path.resolve(paths().public.styleguide + '/styleguide.html')] |
| 117 | + } |
| 118 | + } |
| 119 | + ], |
| 120 | + notify: { |
| 121 | + styles: [ |
| 122 | + 'display: none', |
| 123 | + 'padding: 15px', |
| 124 | + 'font-family: sans-serif', |
| 125 | + 'position: fixed', |
| 126 | + 'font-size: 1em', |
| 127 | + 'z-index: 9999', |
| 128 | + 'bottom: 0px', |
| 129 | + 'right: 0px', |
| 130 | + 'border-top-left-radius: 5px', |
| 131 | + 'background-color: #1B2032', |
| 132 | + 'opacity: 0.4', |
| 133 | + 'margin: 0', |
| 134 | + 'color: white', |
| 135 | + 'text-align: center' |
| 136 | + ] |
| 137 | + } |
| 138 | + } |
| 139 | + } |
| 140 | + }, |
| 141 | + bsReload: { |
| 142 | + css: path.resolve(paths().public.root + '**/*.css') |
| 143 | + } |
| 144 | + }); |
145 | 145 |
|
146 | | - // load all grunt tasks |
147 | | - require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); |
| 146 | + // load all grunt tasks |
| 147 | + require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); |
148 | 148 |
|
149 | | - //load the patternlab task |
150 | | - grunt.task.loadTasks('./builder/'); |
| 149 | + //load the patternlab task |
| 150 | + grunt.task.loadTasks('./builder/'); |
151 | 151 |
|
152 | | - grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']); |
| 152 | + grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']); |
153 | 153 |
|
154 | | - //travis CI task |
155 | | - grunt.registerTask('travis', ['nodeunit', 'patternlab']); |
| 154 | + //travis CI task |
| 155 | + grunt.registerTask('travis', ['nodeunit', 'patternlab']); |
156 | 156 |
|
157 | | - grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']); |
| 157 | + grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']); |
158 | 158 |
|
159 | | - grunt.registerTask('build', ['nodeunit', 'concat']); |
| 159 | + grunt.registerTask('build', ['nodeunit', 'concat']); |
160 | 160 |
|
161 | 161 | }; |
0 commit comments