Skip to content

Commit 726cb9a

Browse files
author
Chris Ferdinandi
committed
Merge branch 'gulpjs'
2 parents b824e29 + 3864b95 commit 726cb9a

File tree

11 files changed

+552
-10
lines changed

11 files changed

+552
-10
lines changed

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
.DS_Store
1+
# Node
2+
node_modules
3+
test/results
4+
test/coverage
5+
6+
## OS X
7+
.DS_Store
8+
._*
9+
.Spotlight-V100
10+
.Trashes

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- "0.11"
4+
- "0.10"
5+
before_script:
6+
- npm install -g gulp
7+
script: gulp

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Smooth Scroll
1+
# Smooth Scroll [![Build Status](https://travis-ci.org/cferdinandi/smooth-scroll.svg)](https://travis-ci.org/cferdinandi/smooth-scroll)
22
A lightweight script to animate scrolling to anchor links.
33

44
[Download Smooth Scroll 4](https://github.com/cferdinandi/smooth-scroll/archive/master.zip) / [View the demo](http://cferdinandi.github.io/smooth-scroll/)
@@ -19,10 +19,12 @@ A lightweight script to animate scrolling to anchor links.
1919

2020
## Getting Started
2121

22+
Compiled and production-ready code can be found in the `dist` directory. The `src` directory contains development code. Unit tests are located in the `test` directory.
23+
2224
### 1. Include Smooth Scroll on your site.
2325

2426
```html
25-
<script src="js/smooth-scroll.js"></script>
27+
<script src="dist/js/smooth-scroll.js"></script>
2628
```
2729

2830
### 2. Add the markup to your HTML.
@@ -201,6 +203,10 @@ Smooth Scroll is licensed under the [MIT License](http://gomakethings.com/mit/).
201203

202204
## Changelog
203205

206+
* v4.8.0 - June 21, 2014
207+
* Converted to gulp.js workflow.
208+
* Added unit testing.
209+
* Added minified versions of files.
204210
* v4.7.2 - June 19, 2014
205211
* Fixed typo that broke scroll.
206212
* v4.7.1 - June 19, 2014
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/**
2-
* Smooth Scroll v4.7.2
2+
* smooth-scroll v4.8.0
33
* Animate scrolling to anchor links, by Chris Ferdinandi.
4-
* http://gomakethings.com
5-
*
6-
* Additional contributors:
7-
* https://github.com/cferdinandi/smooth-scroll#contributors
8-
*
4+
* http://github.com/cferdinandi/smooth-scroll
5+
*
96
* Free to use under the MIT License.
107
* http://gomakethings.com/mit/
118
*/

dist/js/smooth-scroll.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
var gulp = require('gulp');
2+
var plumber = require('gulp-plumber');
3+
var clean = require('gulp-clean');
4+
var rename = require('gulp-rename');
5+
var flatten = require('gulp-flatten');
6+
var tap = require('gulp-tap');
7+
var header = require('gulp-header');
8+
var jshint = require('gulp-jshint');
9+
var stylish = require('jshint-stylish');
10+
var concat = require('gulp-concat');
11+
var uglify = require('gulp-uglify');
12+
var sass = require('gulp-sass');
13+
var prefix = require('gulp-autoprefixer');
14+
var minify = require('gulp-minify-css');
15+
var karma = require('gulp-karma');
16+
var package = require('./package.json');
17+
18+
var paths = {
19+
output : 'dist/',
20+
scripts : {
21+
input : [ 'src/js/*' ],
22+
output : 'dist/js/'
23+
},
24+
styles : {
25+
input : 'src/sass/**/*.scss',
26+
output : 'dist/css/'
27+
},
28+
sass : {
29+
input : 'src/sass/*',
30+
output : 'dist/sass/',
31+
},
32+
static : 'src/static/**',
33+
test : {
34+
spec : [ 'test/spec/**/*.js' ],
35+
coverage: 'test/coverage/',
36+
results: 'test/results/'
37+
}
38+
};
39+
40+
var banner = {
41+
full :
42+
'/**\n' +
43+
' * <%= package.name %> v<%= package.version %>\n' +
44+
' * <%= package.description %>, by <%= package.author.name %>.\n' +
45+
' * <%= package.repository.url %>\n' +
46+
' * \n' +
47+
' * Free to use under the MIT License.\n' +
48+
' * http://gomakethings.com/mit/\n' +
49+
' */\n\n',
50+
min :
51+
'/**' +
52+
' <%= package.name %> v<%= package.version %>, by Chris Ferdinandi' +
53+
' | <%= package.repository.url %>' +
54+
' | Licensed under MIT: http://gomakethings.com/mit/' +
55+
' */\n'
56+
};
57+
58+
gulp.task('scripts', ['clean'], function() {
59+
return gulp.src(paths.scripts.input)
60+
.pipe(plumber())
61+
.pipe(flatten())
62+
63+
.pipe(tap(function (file, t) {
64+
if ( file.stat.isDirectory() ) {
65+
var name = file.relative + '.js';
66+
return gulp.src(file.path + '/*.js')
67+
.pipe(concat(name))
68+
.pipe(header(banner.full, { package : package }))
69+
.pipe(gulp.dest(paths.scripts.output))
70+
.pipe(rename({ suffix: '.min' }))
71+
.pipe(uglify())
72+
.pipe(header(banner.min, { package : package }))
73+
.pipe(gulp.dest(paths.scripts.output));
74+
}
75+
}))
76+
77+
// Don't add headers to classList.js
78+
.pipe(tap(function (file,t) {
79+
if ( file.relative === 'classList.js' ) {
80+
return gulp.src( file.path )
81+
.pipe(gulp.dest(paths.scripts.output))
82+
.pipe(rename({ suffix: '.min' }))
83+
.pipe(uglify())
84+
.pipe(gulp.dest(paths.scripts.output));
85+
}
86+
}))
87+
88+
.pipe(header(banner.full, { package : package }))
89+
.pipe(gulp.dest(paths.scripts.output))
90+
.pipe(rename({ suffix: '.min' }))
91+
.pipe(uglify())
92+
.pipe(header(banner.min, { package : package }))
93+
.pipe(gulp.dest(paths.scripts.output));
94+
});
95+
96+
gulp.task('styles', ['clean'], function() {
97+
return gulp.src(paths.styles.input)
98+
.pipe(plumber())
99+
.pipe(sass())
100+
.pipe(flatten())
101+
.pipe(prefix('last 2 version', '> 1%'))
102+
.pipe(header(banner.full, { package : package }))
103+
.pipe(gulp.dest(paths.styles.output))
104+
.pipe(rename({ suffix: '.min' }))
105+
.pipe(minify())
106+
.pipe(header(banner.min, { package : package }))
107+
.pipe(gulp.dest(paths.styles.output));
108+
});
109+
110+
gulp.task('sass', ['clean'], function() {
111+
return gulp.src(paths.sass.input)
112+
.pipe(plumber())
113+
.pipe(flatten())
114+
.pipe(tap(function (file, t) {
115+
if ( file.stat.isDirectory() ) {
116+
return gulp.src(file.path + '/*.scss')
117+
.pipe(header(banner.full, { package : package }))
118+
.pipe(gulp.dest(paths.sass.output + '/components'));
119+
}
120+
}))
121+
.pipe(gulp.dest(paths.sass.output));
122+
});
123+
124+
gulp.task('static', ['clean'], function() {
125+
return gulp.src(paths.static)
126+
.pipe(plumber())
127+
.pipe(gulp.dest(paths.output));
128+
});
129+
130+
gulp.task('lint', function () {
131+
return gulp.src(paths.scripts.input)
132+
.pipe(plumber())
133+
.pipe(jshint())
134+
.pipe(jshint.reporter('jshint-stylish'));
135+
});
136+
137+
gulp.task('clean', function () {
138+
return gulp.src([
139+
paths.output,
140+
paths.test.coverage,
141+
paths.test.results
142+
], { read: false })
143+
.pipe(plumber())
144+
.pipe(clean());
145+
});
146+
147+
gulp.task('test', function() {
148+
return gulp.src(paths.scripts.input.concat(paths.test.spec))
149+
.pipe(plumber())
150+
.pipe(karma({ configFile: 'test/karma.conf.js' }))
151+
.on('error', function(err) { throw err; });
152+
});
153+
154+
gulp.task('default', [
155+
'lint',
156+
'clean',
157+
'scripts',
158+
'styles',
159+
'sass',
160+
'static',
161+
'test'
162+
]);

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h1 style="text-align: center; font-size: 3em; margin-bottom: 0;">Smooth Scroll<
6969

7070

7171
<!-- Javascript -->
72-
<script src='smooth-scroll.js'></script>
72+
<script src='dist/js/smooth-scroll.js'></script>
7373
<script>
7474
smoothScroll.init({
7575
speed: 1000,

package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "smooth-scroll",
3+
"version": "4.8.0",
4+
"description": "Animate scrolling to anchor links",
5+
"author": {
6+
"name": "Chris Ferdinandi",
7+
"url": "http://gomakethings.com"
8+
},
9+
"license": "MIT",
10+
"repository": {
11+
"type": "git",
12+
"url": "http://github.com/cferdinandi/smooth-scroll"
13+
},
14+
"devDependencies": {
15+
"gulp": "~3.8.0",
16+
"gulp-autoprefixer": "0.0.7",
17+
"gulp-clean": "^0.2.4",
18+
"gulp-concat": "~2.2.0",
19+
"gulp-flatten": "~0.0.2",
20+
"gulp-tap": "~0.1.1",
21+
"gulp-header": "^1.0.2",
22+
"gulp-jshint": "^1.6.1",
23+
"gulp-karma": "0.0.4",
24+
"gulp-minify-css": "~0.3.4",
25+
"gulp-plumber": "~0.6.2",
26+
"gulp-rename": "~1.1.0",
27+
"gulp-sass": "~0.7.2",
28+
"gulp-uglify": "~0.3.0",
29+
"jshint-stylish": "^0.2.0",
30+
"karma": "^0.12.16",
31+
"karma-coverage": "^0.2.4",
32+
"karma-jasmine": "~0.2.0",
33+
"karma-phantomjs-launcher": "^0.1.4",
34+
"karma-spec-reporter": "0.0.13",
35+
"karma-htmlfile-reporter": "~0.1"
36+
}
37+
}

0 commit comments

Comments
 (0)