Skip to content

Commit e60d31e

Browse files
author
Mehdy Dara
committed
Merge pull request #466 from Swiip/always-use-vendor-css-prepro
Add a vendor.cssPreprocessor in all cases
2 parents 6686735 + f08778d commit e60d31e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+155
-89
lines changed

app/src/router.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ module.exports = function(GulpAngularGenerator) {
1111

1212
if (this.props.router.module === 'ngRoute') {
1313
this.routerHtml = '<div ng-view></div>';
14-
this.routerJs = this.fs.read(this.templatePath('src/app/__ngroute.' + this.props.jsPreprocessor.extension));
14+
this.routerJs = this.fs.read(this.templatePath('src/app/_ngroute/__ngroute.' + this.props.jsPreprocessor.extension));
1515
} else if (this.props.router.module === 'ui.router') {
1616
this.routerHtml = '<div ui-view></div>';
17-
this.routerJs = this.fs.read(this.templatePath('src/app/__uirouter.' + this.props.jsPreprocessor.extension));
17+
this.routerJs = this.fs.read(this.templatePath('src/app/_uirouter/__uirouter.' + this.props.jsPreprocessor.extension));
1818
} else {
1919
this.routerHtml = this.fs.read(this.templatePath(routerPartialSrc));
2020
this.routerHtml = this.routerHtml.replace(

app/src/ui.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ module.exports = function(GulpAngularGenerator) {
5555
}
5656

5757
this.files.push({
58-
src: 'src/app/__' + this.props.ui.key + '-index.' + this.props.cssPreprocessor.extension,
58+
src: 'src/app/_' + this.props.ui.key + '/__' + this.props.ui.key + '-index.' + this.props.cssPreprocessor.extension,
5959
dest: 'src/app/index.' + this.props.cssPreprocessor.extension,
6060
template: false
6161
});
6262

63-
if(this.isVendorStylesPreprocessed && this.props.ui.key !== 'none') {
63+
if(this.props.cssPreprocessor.key !== 'none') {
6464
this.files.push({
65-
src: 'src/app/__' + this.props.ui.key + '-vendor.' + this.props.cssPreprocessor.extension,
65+
src: 'src/app/_' + this.props.ui.key + '/__' + this.props.ui.key + '-vendor.' + this.props.cssPreprocessor.extension,
6666
dest: 'src/app/vendor.' + this.props.cssPreprocessor.extension,
6767
template: true
6868
});
@@ -80,7 +80,7 @@ module.exports = function(GulpAngularGenerator) {
8080
if (this.props.ui.key === 'bootstrap') {
8181
if(this.props.bootstrapComponents.key !== 'official') {
8282
if(this.props.cssPreprocessor.extension === 'scss') {
83-
this.wiredepExclusions.push('/bootstrap-sass-official/');
83+
this.wiredepExclusions.push('/bootstrap-sass-official\\/.*\\.js/');
8484
} else {
8585
this.wiredepExclusions.push('/bootstrap\\.js/');
8686
}

app/templates/_gulpfile.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
var gulp = require('gulp');
44
var gutil = require('gulp-util');
5-
var _ = require('lodash');
65
var wrench = require('wrench');
76

87
var options = {
@@ -15,6 +14,12 @@ var options = {
1514
gutil.log(gutil.colors.red('[' + title + ']'), err.toString());
1615
this.emit('end');
1716
};
17+
},
18+
wiredep: {
19+
directory: 'bower_components'
20+
<% if(wiredepExclusions.length > 0) { %>,
21+
exclude: [<%= wiredepExclusions.join(', ') %>]
22+
<% } %>
1823
}
1924
};
2025

app/templates/gulp/_inject.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ module.exports = function(options) {
1919
options.src + '/app/**/*.css'
2020
], { read: false });
2121
<% } %>
22-
2322
<% if (props.jsPreprocessor.key === 'typescript') { %>
23+
2424
var sortOutput = require('../' + options.tmp + '/sortOutput.json');
2525
<% } %>
2626

@@ -49,17 +49,10 @@ module.exports = function(options) {
4949
addRootSlash: false
5050
};
5151

52-
var wiredepOptions = {
53-
directory: 'bower_components'
54-
<% if(wiredepExclusions.length > 0) { %>,
55-
exclude: [<%= wiredepExclusions.join(', ') %>]
56-
<% } %>
57-
};
58-
5952
return gulp.src(options.src + '/*.html')
6053
.pipe($.inject(injectStyles, injectOptions))
6154
.pipe($.inject(injectScripts, injectOptions))
62-
.pipe(wiredep(wiredepOptions))
55+
.pipe(wiredep(options.wiredep))
6356
.pipe(gulp.dest(options.tmp + '/serve'));
6457

6558
});

app/templates/gulp/_styles.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var browserSync = require('browser-sync');
55

66
var $ = require('gulp-load-plugins')();
77

8+
var wiredep = require('wiredep').stream;
9+
810
module.exports = function(options) {
911
gulp.task('styles', function () {
1012
<% if (props.cssPreprocessor.key === 'less') { %>
@@ -37,6 +39,7 @@ module.exports = function(options) {
3739
};
3840

3941
var indexFilter = $.filter('index.<%= props.cssPreprocessor.extension %>');
42+
var vendorFilter = $.filter('vendor.<%= props.cssPreprocessor.extension %>');
4043
<% if (props.cssPreprocessor.key === 'ruby-sass') { %>
4144
var cssFilter = $.filter('**/*.css');
4245
<% } %>
@@ -45,28 +48,31 @@ module.exports = function(options) {
4548
options.src + '/app/index.<%= props.cssPreprocessor.extension %>',
4649
options.src + '/app/vendor.<%= props.cssPreprocessor.extension %>'
4750
])
48-
.pipe(indexFilter)
49-
.pipe($.inject(injectFiles, injectOptions))
50-
.pipe(indexFilter.restore())
51+
.pipe(indexFilter)
52+
.pipe($.inject(injectFiles, injectOptions))
53+
.pipe(indexFilter.restore())
54+
.pipe(vendorFilter)
55+
.pipe(wiredep(options.wiredep))
56+
.pipe(vendorFilter.restore())
5157
<% if (props.cssPreprocessor.key === 'ruby-sass') { %>
52-
.pipe($.rubySass(sassOptions)).on('error', options.errorHandler('RubySass'))
53-
.pipe(cssFilter)
54-
.pipe($.sourcemaps.init({ loadMaps: true }))
58+
.pipe($.rubySass(sassOptions)).on('error', options.errorHandler('RubySass'))
59+
.pipe(cssFilter)
60+
.pipe($.sourcemaps.init({ loadMaps: true }))
5561
<% } else { %>
56-
.pipe($.sourcemaps.init())
62+
.pipe($.sourcemaps.init())
5763
<% } if (props.cssPreprocessor.key === 'less') { %>
58-
.pipe($.less(lessOptions)).on('error', options.errorHandler('Less'))
64+
.pipe($.less(lessOptions)).on('error', options.errorHandler('Less'))
5965
<% } else if (props.cssPreprocessor.key === 'node-sass') { %>
60-
.pipe($.sass(sassOptions)).on('error', options.errorHandler('Sass'))
66+
.pipe($.sass(sassOptions)).on('error', options.errorHandler('Sass'))
6167
<% } else if (props.cssPreprocessor.key === 'stylus') { %>
62-
.pipe($.stylus()).on('error', options.errorHandler('Stylus'))
68+
.pipe($.stylus()).on('error', options.errorHandler('Stylus'))
6369
<% } %>
64-
.pipe($.autoprefixer()).on('error', options.errorHandler('Autoprefixer'))
65-
.pipe($.sourcemaps.write())
70+
.pipe($.autoprefixer()).on('error', options.errorHandler('Autoprefixer'))
71+
.pipe($.sourcemaps.write())
6672
<% if (props.cssPreprocessor.key === 'ruby-sass') { %>
67-
.pipe(cssFilter.restore())
73+
.pipe(cssFilter.restore())
6874
<% } %>
69-
.pipe(gulp.dest(options.tmp + '/serve/app/'))
70-
.pipe(browserSync.reload({ stream: true }));
75+
.pipe(gulp.dest(options.tmp + '/serve/app/'))
76+
.pipe(browserSync.reload({ stream: true }));
7177
});
7278
};

app/templates/gulp/_unit-tests.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ var _ = require('lodash');
1111

1212
module.exports = function(options) {
1313
function listFiles(callback) {
14-
var bowerDeps = wiredep({
15-
directory: 'bower_components',
16-
<% if(wiredepExclusions.length > 0) { %>
17-
exclude: [<%= wiredepExclusions.join(', ') %>],
18-
<% } %>
14+
var wiredepOptions = _.extend({}, options.wiredep, {
1915
dependencies: true,
2016
devDependencies: true
2117
});
18+
var bowerDeps = wiredep(wiredepOptions);
2219

2320
var specFiles = [
2421
options.src + '/**/*.spec.js',

app/templates/src/_index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
99

1010
<!-- build:css({<%= props.paths.tmp %>/serve,<%= props.paths.src %>}) styles/vendor.css -->
11-
<% if (isVendorStylesPreprocessed) { %>
11+
<% if (props.cssPreprocessor.key !== 'none') { %>
1212
<link rel="stylesheet" href="app/vendor.css">
13-
<% } else if (props.ui.key === 'bootstrap') { %>
14-
<link rel="stylesheet" href="<%= computedPaths.appToBower %>/bower_components/bootstrap/dist/css/bootstrap.css">
15-
<% } %>
13+
<% } %>
1614
<!-- bower:css -->
1715
<!-- run `gulp inject` to automatically populate bower styles dependencies -->
1816
<!-- endbower -->

app/templates/src/app/__bootstrap-vendor.less

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/templates/src/app/__bootstrap-vendor.scss

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/templates/src/app/__foundation-vendor.scss

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/templates/src/app/__none-vendor.less

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/templates/src/app/__none-vendor.scss

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/templates/src/app/__angular-material-index.less renamed to app/templates/src/app/_angular-material/__angular-material-index.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@ section.jumbotron {
5353
}
5454
}
5555
}
56+
57+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
58+
all your less files automatically */
5659
// injector
5760
// endinjector

app/templates/src/app/__angular-material-index.scss renamed to app/templates/src/app/_angular-material/__angular-material-index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@ section.jumbotron {
5353
}
5454
}
5555
}
56+
57+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
58+
all your sass files automatically */
5659
// injector
5760
// endinjector

app/templates/src/app/__angular-material-index.styl renamed to app/templates/src/app/_angular-material/__angular-material-index.styl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@ section
4141
&.pull-right
4242
float right
4343
width 50px
44+
45+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
46+
all your stylus files automatically */
4447
// injector
4548
// endinjector
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
less dependencies when defined in the bower.json of your dependencies */
3+
// bower:less
4+
// endbower
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
sass dependencies when defined in the bower.json of your dependencies */
3+
// bower:scss
4+
// endbower
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
stylus dependencies when defined in the bower.json of your dependencies */
3+
// bower:styl
4+
// endbower

app/templates/src/app/__bootstrap-index.less renamed to app/templates/src/app/_bootstrap/__bootstrap-index.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
width: 50px;
1313
}
1414
}
15+
16+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
17+
all your less files automatically */
1518
// injector
1619
// endinjector

app/templates/src/app/__bootstrap-index.scss renamed to app/templates/src/app/_bootstrap/__bootstrap-index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
width: 50px;
1313
}
1414
}
15+
16+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
17+
all your sass files automatically */
1518
// injector
1619
// endinjector

app/templates/src/app/__bootstrap-index.styl renamed to app/templates/src/app/_bootstrap/__bootstrap-index.styl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99

1010
img.pull-right
1111
width 50px
12+
13+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
14+
all your stylus files automatically */
1215
// injector
1316
// endinjector
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
less dependencies when defined in the bower.json of your dependencies */
3+
// bower:less
4+
// endbower
5+
6+
@icon-font-path: '../<%= computedPaths.appToBower %>/bower_components/bootstrap/fonts/';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$icon-font-path: "../<%= computedPaths.appToBower %>/bower_components/bootstrap-sass-official/assets/fonts/bootstrap/";
2+
3+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
4+
sass dependencies when defined in the bower.json of your dependencies */
5+
// bower:scss
6+
// endbower
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
stylus dependencies when defined in the bower.json of your dependencies */
3+
// bower:styl
4+
// endbower

app/templates/src/app/__foundation-index.less renamed to app/templates/src/app/_foundation/__foundation-index.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
width: 50px;
1818
}
1919
}
20+
21+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
22+
all your less files automatically */
2023
// injector
2124
// endinjector

app/templates/src/app/__foundation-index.scss renamed to app/templates/src/app/_foundation/__foundation-index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@
1717
width: 50px;
1818
}
1919
}
20+
21+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
22+
all your sass files automatically */
2023
// injector
2124
// endinjector

app/templates/src/app/__foundation-index.styl renamed to app/templates/src/app/_foundation/__foundation-index.styl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313

1414
img.right
1515
width 50px
16+
17+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
18+
all your stylus files automatically */
1619
// injector
1720
// endinjector
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
less dependencies when defined in the bower.json of your dependencies */
3+
// bower:less
4+
// endbower
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* The import of foundation is made manually because there is still no links of the
2+
sass version in theit bower.json... */
3+
@import '../<%= computedPaths.appToBower %>/bower_components/foundation/scss/foundation';
4+
5+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
6+
sass dependencies when defined in the bower.json of your dependencies */
7+
// bower:scss
8+
// endbower
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
stylus dependencies when defined in the bower.json of your dependencies */
3+
// bower:styl
4+
// endbower

app/templates/src/app/__none-index.less renamed to app/templates/src/app/_none/__none-index.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,8 @@ a {
114114
hr {
115115
clear: both;
116116
}
117+
118+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
119+
all your less files automatically */
117120
// injector
118121
// endinjector

app/templates/src/app/__none-index.scss renamed to app/templates/src/app/_none/__none-index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,8 @@ a {
114114
hr {
115115
clear: both;
116116
}
117+
118+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
119+
all your sass files automatically */
117120
// injector
118121
// endinjector

app/templates/src/app/__none-index.styl renamed to app/templates/src/app/_none/__none-index.styl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,8 @@ a
112112

113113
hr
114114
clear both
115+
116+
/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
117+
all your stylus files automatically */
115118
// injector
116119
// endinjector
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
less dependencies when defined in the bower.json of your dependencies */
3+
// bower:less
4+
// endbower
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
sass dependencies when defined in the bower.json of your dependencies */
3+
// bower:scss
4+
// endbower
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
2+
stylus dependencies when defined in the bower.json of your dependencies */
3+
// bower:styl
4+
// endbower

test/node/test-router.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ describe('gulp-angular generator techs script', function () {
3030
ui: { key: 'testUi' },
3131
jsPreprocessor: { extension: 'testExtension' }
3232
};
33-
read.withArgs('template/src/app/__ngroute.testExtension')
33+
read.withArgs('template/src/app/_ngroute/__ngroute.testExtension')
3434
.returns('my test content 1');
3535
generator.computeRouter();
3636
generator.routerHtml.should.match(/ng-view/);
3737
generator.routerJs.should.equal('my test content 1');
3838

3939
generator.props.router.module = 'ui.router';
40-
read.withArgs('template/src/app/__uirouter.testExtension')
40+
read.withArgs('template/src/app/_uirouter/__uirouter.testExtension')
4141
.returns('my test content 2');
4242
generator.computeRouter();
4343
generator.routerHtml.should.match(/ui-view/);

0 commit comments

Comments
 (0)