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

54 files changed

Lines changed: 155 additions & 89 deletions

Some content is hidden

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

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.

0 commit comments

Comments
 (0)