Skip to content

Commit 1d13c22

Browse files
core updates and a rewritten gulpfile
1 parent c8d39a2 commit 1d13c22

File tree

7 files changed

+92
-97
lines changed

7 files changed

+92
-97
lines changed

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ StreamBuilder is an automated build environment well suited for HTML, CSS and Ja
88
1. Compile SCSS into minified CSS.
99
2. Minify JavaScript.
1010
3. Move your html/css/JavaScripts and images from the source (working) folder, to the destination folder.
11-
4. Refresh your browser for you as you make changes to your source files. StreamBuilder will create a proxy server and listen on port 3000 of your localhost environment (example: http://localhost:3000/streambuilder/dist).
11+
4. Refresh your browser for you as you make changes to your source files. StreamBuilder will create a proxy server and listen on port 3000 of your localhost environment (example: http://localhost:3000/StreamBuilder/dist).
1212

1313
*__StreamBuilder's workflow__*
1414

@@ -24,6 +24,7 @@ Note: if you run GNU/Linux you can now get the most recent version of Node with
2424
2. Install the node modules listed in the package.json file globally. I.e., `sudo npm install -g <node_module>`
2525
3. From a terminal `cd path/to/streambuilder`
2626
4. `npm update` This will create a new directory "node_modules" where NPM will install all the required node modules.
27+
5. Edit the config.json file to reflect your destination URL.
2728
5. Run `gulp`
2829

2930
## Advanced configuration

Diff for: config.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"configuration": {
3+
"devUrl" : "/StreamBuilder/dist",
4+
5+
"source": {
6+
"style" : "./src/scss/**/*.scss",
7+
"js" : "./src/js/**/*.js",
8+
"html" : "./src/html/**/*.html",
9+
"img" : "./src/img/**/*"
10+
},
11+
12+
"destination": {
13+
"style" : "./dist/css",
14+
"js" : "./dist/js",
15+
"html" : "./dist",
16+
"img" : "./dist/img"
17+
}
18+
}
19+
}

Diff for: gulpfile.js

+65-58
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,103 @@
1-
var /* BEGIN ENVIRONMENT CONFIG */
2-
conf_image_dest = './dist/img', // where to output images
3-
conf_output_dest = './dist', // the base output directory
4-
conf_script_dest = './dist/js', // where to output scripts
5-
conf_style_dest = './dist/css', // where to output styles
6-
conf_template_dest = './dist', // where to output html templates
7-
conf_url_dest = 'http://localhost/StreamBuilder/dist', // the local URL of the project
8-
/* END ENVIRONMENT CONFIG */
9-
10-
browsersync = require('browser-sync'),
11-
changed = require('gulp-changed'),
12-
gulp = require('gulp'),
13-
gulputil = require('gulp-util'),
14-
gulpwatch = require('gulp-watch'), // gulp-watch is not the same as gulp.watch !
15-
path = require('path'),
16-
reload = browsersync.reload,
17-
sass = require('gulp-sass'),
18-
uglify = require('gulp-uglify');
1+
var browserSync = require('browser-sync').create(),
2+
changed = require('gulp-changed'),
3+
config = require('./config.json').configuration,
4+
gulp = require('gulp'),
5+
gulputil = require('gulp-util'),
6+
gulpwatch = require('gulp-watch'),
7+
reload = browserSync.reload,
8+
sass = require('gulp-sass'),
9+
uglify = require('gulp-uglify');
1910

2011
/**
21-
* Compile scss as compressed css
12+
* Style
2213
*/
2314
gulp.task('style', function () {
24-
return gulp.src('./src/scss/layout.scss')
25-
.pipe(changed(conf_style_dest))
15+
return gulp.src(config.source.style)
16+
.pipe(changed(config.destination.style, {extension: '.css'}))
2617
.pipe(sass({'outputStyle': 'compressed'}))
27-
.pipe(gulp.dest(conf_style_dest))
18+
.pipe(gulp.dest(config.destination.style))
2819
.pipe(reload({stream:true}));
2920
});
3021

3122
/**
32-
* HTML
33-
* If the destination file has been changed, reload the page.
23+
* Images
3424
*/
35-
gulp.task('templates', function () {
36-
return gulp.src('./src/html/**')
37-
.pipe(gulp.dest(conf_output_dest))
25+
gulp.task('image', function () {
26+
return gulp.src(config.source.img)
27+
.pipe(changed(config.destination.img))
28+
.pipe(gulp.dest(config.destination.img))
3829
.pipe(reload({stream:true}));
3930
});
4031

4132
/**
42-
* Move images.
33+
* Script
4334
*/
44-
gulp.task('images', function () {
45-
return gulp.src('./src/img/**')
46-
.pipe(gulp.dest(conf_image_dest))
35+
gulp.task('script', function () {
36+
return gulp.src(config.source.js)
37+
.pipe(changed(config.destination.js, {extension: '.js'}))
38+
.pipe(uglify())
39+
.pipe(gulp.dest(config.destination.js))
4740
.pipe(reload({stream:true}));
4841
});
4942

5043
/**
51-
* Compress javascript.
44+
* HTML
5245
*/
53-
gulp.task('scripts', function () {
54-
return gulp.src('./src/js/**')
55-
.pipe(changed(conf_script_dest))
56-
.pipe(uglify())
57-
.pipe(gulp.dest(conf_script_dest))
46+
gulp.task('html', function () {
47+
return gulp.src(config.source.html)
48+
.pipe(changed(config.destination.html, {extension: '.html'}))
49+
.pipe(gulp.dest(config.destination.html))
5850
.pipe(reload({stream:true}));
59-
6051
});
6152

6253
/**
63-
* Start a proxy server
54+
* Server
6455
*/
65-
gulp.task('server', function() {
66-
browsersync({proxy: conf_url_dest});
67-
})
56+
gulp.task('server', function (){
57+
browserSync.init({
58+
proxy: config.devUrl
59+
});
60+
});
6861

6962
/**
70-
* Watch for changed files
63+
* Watch
7164
*/
72-
gulp.task('watch', function () {
73-
// watch for files that were changed
74-
gulp.watch('./src/scss/**/*.scss', ['style']);
75-
gulp.watch('./src/html/**/*.html', ['templates']);
76-
gulp.watch('./src/js/**/*.js', ['scripts']);
77-
// watch for files that are added
78-
gulpwatch('./src/img/**', function () {
79-
gulp.src('./src/img/**')
80-
.pipe(gulp.dest(conf_image_dest))
65+
gulp.task('watch', function (){
66+
67+
gulpwatch(config.source.style, ['style'], function () {
68+
gulp.src(config.source.style)
69+
.pipe(changed(config.destination.style, {extension: '.css'}))
70+
.pipe(sass({'outputStyle': 'compressed'}))
71+
.pipe(gulp.dest(config.destination.style))
8172
.pipe(reload({stream:true}));
8273
});
83-
gulpwatch('./src/js/**', function () {
84-
gulp.src('./src/js/**')
85-
.pipe(gulp.dest(conf_script_dest))
74+
75+
gulpwatch(config.source.img, ['image'], function () {
76+
gulp.src(config.source.img)
77+
.pipe(changed(config.destination.img))
78+
.pipe(gulp.dest(config.destination.img))
79+
.pipe(reload({stream:true}));
80+
});
81+
82+
gulpwatch(config.source.js, ['script'], function () {
83+
gulp.src(config.source.js)
84+
.pipe(changed(config.destination.js, {extension: '.js'}))
85+
.pipe(uglify())
86+
.pipe(gulp.dest(config.destination.js))
87+
.pipe(reload({stream:true}));
88+
});
89+
90+
gulpwatch(config.source.html, ['html'], function () {
91+
gulp.src(config.source.html)
92+
.pipe(changed(config.destination.html, {extension: '.html'}))
93+
.pipe(gulp.dest(config.destination.html))
8694
.pipe(reload({stream:true}));
8795
});
88-
gulputil.log(gulputil.colors.inverse("Shazam! We're up and running."));
8996
});
9097

9198
/**
9299
* Default task
93100
*/
94-
gulp.task('default', ['style', 'templates', 'images', 'scripts', 'server', 'watch'], function () {
95-
// Start all tasks
101+
gulp.task('default', ['style', 'image', 'script', 'html', 'server', 'watch'], function () {
102+
gulputil.log(gulputil.colors.inverse("Excelsior! We're up and running."));
96103
});

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"browser-sync": "^2.18.6",
2929
"gulp": "^3.9.1",
3030
"gulp-changed": "^1.3.2",
31-
"gulp-sass": "^1.3.3",
31+
"gulp-sass": "2.3.2",
3232
"gulp-uglify": "^1.5.4",
3333
"gulp-util": "^3.0.8",
3434
"gulp-watch": "^4.3.11"

Diff for: src/html/index.html

-7
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
</article>
2727
</main>
2828
<footer>
29-
<nav>
30-
<ul>
31-
<li><a href="#" title="home">home</a></li>
32-
<li><a href="#" title="about">about</a></li>
33-
<li><a href="#" title="contact">contact</a></li>
34-
</ul>
35-
</nav>
3629
</footer>
3730
</body>
3831
</html>

Diff for: src/js/main.js

-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
(function ($) {
44
"use strict";
55

6-
76
}(jQuery));

Diff for: src/scss/layout.scss

+5-29
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616

1717

1818

19-
2019
/* - - - - - - - - - - Responsive Breakpoint Styles Here - - - - - - - - - - */
20+
/* XSmall devices and larger */
21+
@include respond(xs) {
22+
23+
}
2124
/* Small devices and larger */
2225
@include respond(sm) {
2326

@@ -36,31 +39,4 @@
3639
/* XLarge devices and larger */
3740
@include respond(xl) {
3841

39-
}
40-
41-
42-
43-
44-
45-
/* - - - - - - - - - - BEGIN DEMO Styles - - - - - - - - - - */
46-
.blue-colp-fixed {
47-
color: #efefef;
48-
background: #58BEE0;
49-
@include colp(.25);
50-
}
51-
.red-colp-fixed {
52-
color: #efefef;
53-
background: #E05858;
54-
@include colp(.75);
55-
}
56-
.blue-colu-fixed {
57-
color: #efefef;
58-
background: #58BEE0;
59-
@include colu(2.4, 7);
60-
}
61-
.red-colu-fixed {
62-
color: #efefef;
63-
background: #E05858;
64-
@include colu(4.6, 7);
65-
}
66-
/* - - - - - - - - - - END DEMO Styles - - - - - - - - - - */
42+
}

0 commit comments

Comments
 (0)