Skip to content

Commit

Permalink
Should copy vendors css and fonts to dist folders as reported here: p…
Browse files Browse the repository at this point in the history
…aislee/healthy-gulp-angular/#3
  • Loading branch information
Carlo Alberto Degli Atti authored and Carlo Alberto Degli Atti committed Jul 25, 2015
1 parent 3cfd53b commit 64afa9c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
7 changes: 6 additions & 1 deletion app/components/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@

<p>
<div demo-component></div>
</p>
</p>


<button type="button" class="btn btn-default" aria-label="Left Align">
<span class="glyphicon glyphicon-align-left" aria-hidden="true"></span>
</button>
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
<!-- inject:js -->
<!-- endinject -->
</body>
</html>
</html>
6 changes: 4 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"angular": "^1.3.12",
"angular-ui-router": "^0.2.11",
"angular-animate": "^1.3.0",
"foundation": "~5.5.1"
"foundation": "~5.5.1",
"angular-bootstrap": "~0.13.1",
"bootstrap-css": "~3.3.4"
},
"devDependencies": {
"angular-mocks": "^1.2.23"
Expand All @@ -17,4 +19,4 @@
"main": "js/foundation.js"
}
}
}
}
32 changes: 29 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ var paths = {
scriptsDevServer: 'devServer/**/*.js'
};

var vendorScriptsRegex = /.js$/i;
var vendorStylesRegex = /.css$/i;

// == PIPE SEGMENTS ========

var pipes = {};
Expand Down Expand Up @@ -68,7 +71,10 @@ pipes.builtVendorScriptsDev = function() {
};

pipes.builtVendorScriptsProd = function() {
return gulp.src(bowerFiles())
return gulp.src(bowerFiles({
filter: function(e) { return vendorScriptsRegex.test(e); }
})
)
.pipe(pipes.orderedVendorScripts())
.pipe(plugins.concat('vendor.min.js'))
.pipe(plugins.uglify())
Expand Down Expand Up @@ -107,6 +113,16 @@ pipes.builtStylesDev = function() {
.pipe(gulp.dest(paths.distDev));
};

pipes.builtVendorStyles = function() {
return gulp.src(bowerFiles({
filter: function(e) { return vendorStylesRegex.test(e); }
})
)
.pipe(plugins.concat('vendor.min.css'))
.pipe(plugins.minifyCss())
.pipe(gulp.dest(paths.distProd + "/styles"));
}

pipes.builtStylesProd = function() {
return gulp.src(paths.styles)
.pipe(plugins.sourcemaps.init())
Expand All @@ -117,6 +133,14 @@ pipes.builtStylesProd = function() {
.pipe(gulp.dest(paths.distProd));
};

pipes.processedFonts = function(base_path) {
return gulp.src('./bower_components/**/*.{ttf,woff,eof,svg,woff2}')
.pipe(plugins.rename(function (path) {
path.dirname = "/";
}))
.pipe(gulp.dest(base_path + '/fonts'));
};

pipes.processedImagesDev = function() {
return gulp.src(paths.images)
.pipe(gulp.dest(paths.distDev + '/images/'));
Expand Down Expand Up @@ -156,22 +180,24 @@ pipes.builtIndexProd = function() {
var vendorScripts = pipes.builtVendorScriptsProd();
var appScripts = pipes.builtAppScriptsProd();
var appStyles = pipes.builtStylesProd();
var vendorStyles = pipes.builtVendorStyles();

return pipes.validatedIndex()
.pipe(gulp.dest(paths.distProd)) // write first to get relative path for inject
.pipe(plugins.inject(vendorScripts, {relative: true, name: 'bower'}))
.pipe(plugins.inject(appScripts, {relative: true}))
.pipe(plugins.inject(appStyles, {relative: true}))
.pipe(plugins.inject(vendorStyles, {relative: true, name: 'bower'}))
.pipe(plugins.htmlmin({collapseWhitespace: true, removeComments: true}))
.pipe(gulp.dest(paths.distProd));
};

pipes.builtAppDev = function() {
return es.merge(pipes.builtIndexDev(), pipes.builtPartialsDev(), pipes.processedImagesDev());
return es.merge(pipes.builtIndexDev(), pipes.builtPartialsDev(), pipes.processedFonts(paths.distDev), pipes.processedImagesDev());
};

pipes.builtAppProd = function() {
return es.merge(pipes.builtIndexProd(), pipes.processedImagesProd());
return es.merge(pipes.builtIndexProd(), pipes.processedFonts(paths.distProd), pipes.processedImagesProd());
};

// == TASKS ========
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"express": "^4.7.2",
"gulp": "^3.8.10",
"gulp-angular-filesort": "^1.0.4",
"gulp-bower-assets": "0.0.3",
"gulp-concat": "^2.4.3",
"gulp-htmlhint": "0.0.9",
"gulp-htmlmin": "^1.0.0",
Expand All @@ -23,13 +24,13 @@
"gulp-nodemon": "^1.0.5",
"gulp-order": "^1.1.1",
"gulp-print": "^1.1.0",
"gulp-rename": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^1.3.2",
"gulp-sourcemaps": "^1.3.0",
"gulp-uglify": "^1.1.0",
"jshint-stylish": "^1.0.0",
"karma": "^0.10",
"karma-junit-reporter": "^0.2.2",
"karma": "^0.13.3",
"karma-junit-reporter": "^0.3.3",
"main-bower-files": "^2.5.0",
"method-override": "^2.1.2",
"protractor": "^1.1.1",
Expand All @@ -40,5 +41,6 @@
"postinstall": "bower install",
"prestart": "npm install",
"start": "node server.js"
}
},
"dependencies": {}
}

0 comments on commit 64afa9c

Please sign in to comment.