Skip to content

Commit a996929

Browse files
committed
update isVendorPreprocessed and the readme
1 parent 8231876 commit a996929

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,18 @@ The root directory generated for a app with name `gulpAngular` :
107107
* *Unit test (karma)* : out of the box unit test configuration with karma
108108
* *e2e test (protractor)* : out of the box e2e test configuration with protractor
109109
* *browser sync* : full-featured development web server with livereload and devices sync
110-
* *ngHtml2js* : all HTML partials will be converted to JS to be bundled in the application
110+
* *angular-templatecache* : all HTML partials will be converted to JS to be bundled in the application
111111
* **TODO** lazy : don't process files which haven't changed when possible
112112

113113
## Questions the generator will ask
114114
* *jQuery*: jQuery 1.x, 2.x, Zepto, none
115115
* *Angular modules*: animate, cookies, touch, sanitize
116116
* *Resource handler*: ngResource, Restangular, none
117117
* *Router*: ngRoute, UI Router, none
118-
* *UI Framework*: Bootstrap, Foundation, none (depends on the chosen CSS preprocessor)
118+
* *UI Framework*: Bootstrap, Foundation, Angular Material, none (depends on the chosen CSS preprocessor)
119119
* *CSS pre-processor*: Less, Sass with Ruby and Node, Stylus, none
120-
* **TODO** Bootstrap directives : UI Bootstrap, Angular Strap, none (only if you chose Bootstrap)
121-
* **TODO** JS preprocessor: CoffeeScript, TypeScript, ECMAScript6 (Traceur)
120+
* *Bootstrap directives* : UI Bootstrap, Angular Strap, official Bootstrap JavaScript, none (only if you chose Bootstrap)
121+
* **TODO** JS preprocessor: CoffeeScript, TypeScript, ECMAScript6 (Traceur and 6to5)
122122
* **TODO** HTML preprocessor: Jade ?
123123
* **TODO** Script loader: Require, Browserify, ES6 with Require?, none
124124
* **TODO** Test framework: Jasmine, Mocha, Qunit

app/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@ var chalk = require('chalk');
77

88
var prompts = require('./prompts.json');
99

10-
var _;
11-
1210
var GulpAngularGenerator = yeoman.generators.Base.extend({
1311

1412
init: function () {
15-
_ = this._;
16-
1713
// Define the appName
1814
this.argument('appName', {
1915
type: String,
@@ -58,7 +54,7 @@ var GulpAngularGenerator = yeoman.generators.Base.extend({
5854

5955
var done = this.async();
6056

61-
_.findWhere(prompts, {name: 'bootstrapComponents'}).when = function(props) {
57+
this._.findWhere(prompts, {name: 'bootstrapComponents'}).when = function(props) {
6258
return props.ui.key === 'bootstrap';
6359
};
6460

app/src/format.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,24 @@ module.exports = function () {
110110
var styleAppSrc = 'src/app/__' + uiFileKey + '-index.' + this.props.cssPreprocessor.extension;
111111
this.styleCopies[styleAppSrc] = 'src/app/index.' + this.props.cssPreprocessor.extension;
112112

113-
this.isVendorStylesPreprocessed = !(
114-
this.props.cssPreprocessor.extension === 'css' ||
115-
this.props.cssPreprocessor.extension === 'styl' ||
116-
this.props.ui.key === 'angular-material' ||
117-
this.props.cssPreprocessor.extension === 'less' && this.props.ui.key === 'foundation'
118-
);
113+
// There is 2 ways of dealing with vendor styles
114+
// - If the vendor styles exist in the css preprocessor chosen,
115+
// the best is to include directly the source files
116+
// - If not, the vendor styles are simply added as standard css links
117+
//
118+
// isVendorStylesPreprocessed defines which solution has to be used
119+
// regarding the ui framework and the css preprocessor chosen.
120+
this.isVendorStylesPreprocessed = false;
121+
122+
if(this.props.cssPreprocessor.extension === 'scss') {
123+
if(this.props.ui.key === 'bootstrap' || this.props.ui.key === 'foundation') {
124+
this.isVendorStylesPreprocessed = true;
125+
}
126+
} else if(this.props.cssPreprocessor.extension === 'less') {
127+
if(this.props.ui.key === 'bootstrap') {
128+
this.isVendorStylesPreprocessed = true;
129+
}
130+
}
119131

120132
if(this.isVendorStylesPreprocessed && this.props.ui.name !== null) {
121133
var styleVendorSource = 'src/app/__' + uiFileKey + '-vendor.' + this.props.cssPreprocessor.extension;

app/templates/src/_index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
<% if (props.ui.name !== null) { %>
1010
<!-- build:css({.tmp,src}) styles/vendor.css --><% if (isVendorStylesPreprocessed) { %>
1111
<link rel="stylesheet" href="app/vendor.css"><% } else if (props.ui.key === 'bootstrap') { %>
12-
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css"><% } else if (props.ui.key === 'foundation') { %>
13-
<link rel="stylesheet" href="../bower_components/foundation/css/foundation.css"><% } %>
12+
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css"><% } %>
1413
<!-- bower:css -->
1514
<!-- run `gulp wiredep` to automaticaly populate bower styles dependencies -->
1615
<!-- endbower -->

test/test-files-generate.mocha.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ describe('gulp-angular generator', function () {
470470
]));
471471

472472
assert.fileContent([].concat(expectedGulpContent, [
473-
['src/index.html', /<link rel="stylesheet" href="..\/bower_components\/foundation\/css\/foundation.css">/],
474473
['bower.json', /"foundation": "5.4.x"/],
475474
['package.json', /"gulp-less": "\^1.3.3"/],
476475
]));
@@ -505,7 +504,6 @@ describe('gulp-angular generator', function () {
505504
]));
506505

507506
assert.fileContent([].concat(expectedGulpContent, [
508-
['src/index.html', /<link rel="stylesheet" href="..\/bower_components\/foundation\/css\/foundation.css">/],
509507
['bower.json', /"foundation": "5.4.x"/],
510508
['package.json', /"gulp-stylus": "\^1.3.3"/],
511509
]));
@@ -546,7 +544,6 @@ describe('gulp-angular generator', function () {
546544

547545
// No Gulp task for style
548546
assert.fileContent([
549-
['src/index.html', /<link rel="stylesheet" href="..\/bower_components\/foundation\/css\/foundation.css">/],
550547
['bower.json', /"foundation": "5.4.x"/],
551548
]);
552549
done();

0 commit comments

Comments
 (0)