Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit c77d61e

Browse files
committed
converted project over to browsersync
1 parent 31b4dfc commit c77d61e

17 files changed

+80
-241
lines changed

Gruntfile.js

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ module.exports = function(grunt) {
33
// Project configuration.
44
grunt.initConfig({
55
pkg: grunt.file.readJSON('package.json'),
6-
clean: {
7-
options: { force: true },
8-
files: ['./public/patterns']
9-
},
106
concat: {
117
options: {
128
stripBanners: true,
@@ -63,36 +59,33 @@ module.exports = function(grunt) {
6359
{ expand: true, cwd: './source/fonts/', src: '*', dest: './public/fonts/'},
6460
{ expand: true, cwd: './source/_data/', src: 'annotations.js', dest: './public/data/' }
6561
]
66-
}
67-
},
68-
jshint: {
69-
options: {
70-
"curly": true,
71-
"eqnull": true,
72-
"eqeqeq": true,
73-
"undef": true,
74-
"forin": true,
75-
//"unused": true,
76-
"node": true
7762
},
78-
patternlab: ['Gruntfile.js', './builder/lib/patternlab.js']
63+
css: {
64+
files: [
65+
{ expand: true, cwd: './source/css/', src: '*.css', dest: './public/css/' }
66+
]
67+
}
7968
},
8069
watch: {
81-
// scss: { //scss can be watched if you like
82-
// options: {
83-
// livereload: true
84-
// },
85-
// files: ['source/css/**/*.scss', 'public/styleguide/css/*.scss'],
86-
// tasks: ['default']
87-
// },
8870
all: {
89-
options: {
90-
livereload: true
91-
},
9271
files: [
93-
'source/_patterns/**/*.mustache',
94-
'source/_patterns/**/*.json',
95-
'source/_data/*.json'
72+
'source/css/**/*.css',
73+
'public/styleguide/css/*.css',
74+
'source/_patterns/**/*.mustache',
75+
'source/_patterns/**/*.json',
76+
'source/_data/*.json'
77+
],
78+
tasks: ['default']
79+
},
80+
scss: {
81+
files: ['source/css/**/*.scss', 'public/styleguide/css/*.scss'],
82+
tasks: ['sass', 'copy:css','bsReload:css']
83+
},
84+
patterns: {
85+
files: [
86+
'source/_patterns/**/*.mustache',
87+
'source/_patterns/**/*.json',
88+
'source/_data/*.json'
9689
],
9790
tasks: ['default']
9891
}
@@ -114,16 +107,24 @@ module.exports = function(grunt) {
114107
nodeunit: {
115108
all: ['test/*_tests.js']
116109
},
117-
connect: {
118-
app:{
110+
browserSync: {
111+
dev: {
119112
options: {
120-
port: 9001,
121-
base: './public',
122-
hostname: 'localhost',
123-
open: true,
124-
livereload: 35729
113+
server: './public',
114+
watchTask: true,
115+
plugins: [
116+
{
117+
module: 'bs-html-injector',
118+
options: {
119+
files: './public/index.html'
120+
}
121+
}
122+
]
125123
}
126124
}
125+
},
126+
bsReload: {
127+
css: './public/**/*.css'
127128
}
128129
});
129130

@@ -134,11 +135,15 @@ module.exports = function(grunt) {
134135
grunt.task.loadTasks('./builder/');
135136

136137
//if you choose to use scss, or any preprocessor, you can add it here
137-
grunt.registerTask('default', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);
138+
grunt.registerTask('default', ['patternlab', /*'sass',*/ 'copy:main']);
138139

139140
//travis CI task
140-
grunt.registerTask('travis', ['nodeunit', 'clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);
141+
grunt.registerTask('travis', ['nodeunit', 'patternlab']);
142+
143+
//TODO: this line is more efficient, but you cannot run concurrent watch tasks without another dependency.
144+
//grunt.registerTask('serve', ['patternlab', /*'sass',*/ 'copy:main', 'browserSync', 'watch:patterns', 'watch:scss']);
145+
grunt.registerTask('serve', ['patternlab', /*'sass',*/ 'copy:main', 'browserSync', 'watch:all']);
141146

142-
grunt.registerTask('serve', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy', 'connect', 'watch']);
147+
grunt.registerTask('build', ['nodeunit', 'concat']);
143148

144149
};

builder/lineage_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/list_item_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/media_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/object_factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/parameter_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/pattern_assembler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/pattern_exporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/patternlab.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -36,7 +36,7 @@ var patternlab_engine = function () {
3636
console.log('===============================');
3737
console.log('Command Line Arguments');
3838
console.log('patternlab:only_patterns');
39-
console.log(' > Compiles the patterns only, outputting to ./public/patterns');
39+
console.log(' > Compiles the patterns only, outputting to config.patterns.public');
4040
console.log('patternlab:v');
4141
console.log(' > Retrieve the version of patternlab-node you have installed');
4242
console.log('patternlab:help');
@@ -89,6 +89,10 @@ var patternlab_engine = function () {
8989

9090
pattern_assembler.process_pattern_file(file, patternlab);
9191
});
92+
93+
//delete the contents of config.patterns.public before writing
94+
fs.emptyDirSync(patternlab.config.patterns.public);
95+
9296
//render all patterns last, so lineageR works
9397
patternlab.patterns.forEach(function(pattern, index, patterns){
9498
//render the pattern, but first consolidate any data we may have
@@ -101,13 +105,13 @@ var patternlab_engine = function () {
101105
var patternFooter = pattern_assembler.renderPattern(patternlab.footer, pattern);
102106

103107
//write the compiled template to the public patterns directory
104-
fs.outputFileSync('./public/patterns/' + pattern.patternLink, patternlab.header + pattern.patternPartial + patternFooter);
108+
fs.outputFileSync(patternlab.config.patterns.public + pattern.patternLink, patternlab.header + pattern.patternPartial + patternFooter);
105109

106110
//write the mustache file too
107-
fs.outputFileSync('./public/patterns/' + pattern.patternLink.replace('.html', '.mustache'), entity_encoder.encode(pattern.template));
111+
fs.outputFileSync(patternlab.config.patterns.public + pattern.patternLink.replace('.html', '.mustache'), entity_encoder.encode(pattern.template));
108112

109113
//write the encoded version too
110-
fs.outputFileSync('./public/patterns/' + pattern.patternLink.replace('.html', '.escaped.html'), entity_encoder.encode(pattern.patternPartial));
114+
fs.outputFileSync(patternlab.config.patterns.public + pattern.patternLink.replace('.html', '.escaped.html'), entity_encoder.encode(pattern.patternPartial));
111115
});
112116

113117
//export patterns if necessary
@@ -154,7 +158,7 @@ var patternlab_engine = function () {
154158

155159
var viewAllTemplate = fs.readFileSync('./source/_patternlab-files/viewall.mustache', 'utf8');
156160
var viewAllHtml = pattern_assembler.renderPattern(viewAllTemplate, {partials: viewAllPatterns, patternPartial: patternPartial});
157-
fs.outputFileSync('./public/patterns/' + pattern.flatPatternPath + '/index.html', viewAllHtml);
161+
fs.outputFileSync(patternlab.config.patterns.public + pattern.flatPatternPath + '/index.html', viewAllHtml);
158162
}
159163
}
160164

builder/patternlab_grunt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

0 commit comments

Comments
 (0)