Skip to content

Commit b675f2e

Browse files
author
Emmanouil Konstantinidis
committed
Fonts & Setup progress
1 parent 267edf2 commit b675f2e

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed

gulpfile.js

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,68 @@
1-
var gulp = require('gulp');
2-
var sass = require('gulp-sass');
31
var browserify = require('browserify');
42
var babelify = require('babelify');
3+
var gulp = require('gulp');
4+
var gutil = require('gulp-util');
5+
var sass = require('gulp-sass');
56
var source = require('vinyl-source-stream');
7+
var watchify = require('watchify');
8+
9+
var options = {
10+
browserifyOpts: {
11+
entries: ['./src/js/app.js'],
12+
debug: true,
13+
14+
cache: {},
15+
packageCache: {},
16+
fullPaths: true
17+
},
18+
jsDest: 'dist/js'
19+
};
620

7-
gulp.task('build-js', function () {
8-
return browserify({entries: './src/js/app.js', extensions: ['.js'], debug: true})
9-
.transform(babelify)
10-
.bundle()
11-
.pipe(source('app.js'))
12-
.pipe(gulp.dest('dist/js'));
21+
var bundler = browserify(options.browserifyOpts);
22+
23+
gulp.task('build:js', function () {
24+
return bundler
25+
.transform(babelify)
26+
.bundle()
27+
.pipe(source('app.js'))
28+
.pipe(gulp.dest(options.jsDest));
1329
});
1430

15-
gulp.task('watch-js', ['build-js'], function () {
16-
gulp.watch('./src/js/**/*.js', ['build-js']);
31+
gulp.task('watch:js', function () {
32+
var watcher = bundler
33+
.plugin(watchify, {ignoreWatch: ['**/node_modules/**']})
34+
.transform(babelify);
35+
36+
function bundle() {
37+
return watcher.bundle()
38+
// log errors if they happen
39+
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
40+
.pipe(source('app.js'))
41+
.pipe(gulp.dest(options.jsDest));
42+
};
43+
44+
watcher.on('update', bundle); // on any dep update, runs the bundler
45+
watcher.on('log', gutil.log); // output build logs to terminal
1746
});
1847

19-
gulp.task('build-scss', function () {
48+
gulp.task('build:scss', function () {
2049
return gulp.src('./src/scss/app.scss')
2150
.pipe(sass().on('error', sass.logError))
2251
.pipe(gulp.dest('./dist/css'));
2352
});
2453

25-
gulp.task('watch-scss', ['build-scss'], function () {
54+
gulp.task('watch:scss', function () {
2655
gulp.watch('./src/scss/app.scss', ['build-scss']);
2756
});
2857

29-
gulp.task('build', ['build-js', 'build-scss']);
30-
gulp.task('watch', ['watch-js', 'watch-scss']);
58+
gulp.task('copy:fonts', function () {
59+
return gulp.src([
60+
'./node_modules/font-awesome/fonts/*.+(eot|svg|ttf|woff|woff2|otf)',
61+
'./node_modules/octicons/octicons/*.+(ttf|eot|svg|ttf|woff)',
62+
])
63+
.pipe(gulp.dest('./dist/fonts'));
64+
});
65+
66+
gulp.task('build', ['copy:fonts', 'build:js', 'build:scss']);
67+
gulp.task('watch', ['watch:js', 'watch:scss']);
3168
gulp.task('default', ['build']);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
"babel-cli": "=6.8.0",
7878
"babel-core": "=6.8.0",
7979
"babel-eslint": "=6.0.4",
80-
"babel-loader": "=6.2.4",
8180
"babel-preset-es2015": "=6.6.0",
8281
"babel-preset-react": "=6.5.0",
8382
"babel-preset-stage-0": "=6.5.0",
@@ -91,6 +90,7 @@
9190
"eslint-plugin-react": "=5.1.1",
9291
"gulp": "=3.9.1",
9392
"gulp-sass": "^2.3.1",
93+
"gulp-util": "^3.0.7",
9494
"istanbul": "=1.0.0-alpha.2",
9595
"jsdom": "=9.0.0",
9696
"mocha": "=2.4.5",
@@ -99,6 +99,7 @@
9999
"sass-lint": "=1.7.0",
100100
"sinon": "=1.17.4",
101101
"sinon-chai": "=2.8.0",
102-
"vinyl-source-stream": "^1.1.0"
102+
"vinyl-source-stream": "^1.1.0",
103+
"watchify": "^3.7.0"
103104
}
104105
}

src/scss/app.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ $error-color: #DB423C;
2020

2121
/* @group Fonts Overrides */
2222

23-
$fa-font-path: "../../node_modules/font-awesome/fonts";
23+
$fa-font-path: "../fonts";
2424
@import "node_modules/font-awesome/scss/font-awesome.scss";
2525

26-
$octicons-font-path: "../../node_modules/octicons/octicons";
26+
$octicons-font-path: "../fonts";
2727
@import "node_modules/octicons/octicons/octicons.scss";
2828

2929

0 commit comments

Comments
 (0)