Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a vendor.cssPreprocessor in all cases #466

Merged
merged 4 commits into from
Apr 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ module.exports = function(GulpAngularGenerator) {

if (this.props.router.module === 'ngRoute') {
this.routerHtml = '<div ng-view></div>';
this.routerJs = this.fs.read(this.templatePath('src/app/__ngroute.' + this.props.jsPreprocessor.extension));
this.routerJs = this.fs.read(this.templatePath('src/app/_ngroute/__ngroute.' + this.props.jsPreprocessor.extension));
} else if (this.props.router.module === 'ui.router') {
this.routerHtml = '<div ui-view></div>';
this.routerJs = this.fs.read(this.templatePath('src/app/__uirouter.' + this.props.jsPreprocessor.extension));
this.routerJs = this.fs.read(this.templatePath('src/app/_uirouter/__uirouter.' + this.props.jsPreprocessor.extension));
} else {
this.routerHtml = this.fs.read(this.templatePath(routerPartialSrc));
this.routerHtml = this.routerHtml.replace(
Expand Down
8 changes: 4 additions & 4 deletions app/src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ module.exports = function(GulpAngularGenerator) {
}

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

if(this.isVendorStylesPreprocessed && this.props.ui.key !== 'none') {
if(this.props.cssPreprocessor.key !== 'none') {
this.files.push({
src: 'src/app/__' + this.props.ui.key + '-vendor.' + this.props.cssPreprocessor.extension,
src: 'src/app/_' + this.props.ui.key + '/__' + this.props.ui.key + '-vendor.' + this.props.cssPreprocessor.extension,
dest: 'src/app/vendor.' + this.props.cssPreprocessor.extension,
template: true
});
Expand All @@ -80,7 +80,7 @@ module.exports = function(GulpAngularGenerator) {
if (this.props.ui.key === 'bootstrap') {
if(this.props.bootstrapComponents.key !== 'official') {
if(this.props.cssPreprocessor.extension === 'scss') {
this.wiredepExclusions.push('/bootstrap-sass-official/');
this.wiredepExclusions.push('/bootstrap-sass-official\\/.*\\.js/');
} else {
this.wiredepExclusions.push('/bootstrap\\.js/');
}
Expand Down
7 changes: 6 additions & 1 deletion app/templates/_gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var gulp = require('gulp');
var gutil = require('gulp-util');
var _ = require('lodash');
var wrench = require('wrench');

var options = {
Expand All @@ -15,6 +14,12 @@ var options = {
gutil.log(gutil.colors.red('[' + title + ']'), err.toString());
this.emit('end');
};
},
wiredep: {
directory: 'bower_components'
<% if(wiredepExclusions.length > 0) { %>,
exclude: [<%= wiredepExclusions.join(', ') %>]
<% } %>
}
};

Expand Down
11 changes: 2 additions & 9 deletions app/templates/gulp/_inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module.exports = function(options) {
options.src + '/app/**/*.css'
], { read: false });
<% } %>

<% if (props.jsPreprocessor.key === 'typescript') { %>

var sortOutput = require('../' + options.tmp + '/sortOutput.json');
<% } %>

Expand Down Expand Up @@ -49,17 +49,10 @@ module.exports = function(options) {
addRootSlash: false
};

var wiredepOptions = {
directory: 'bower_components'
<% if(wiredepExclusions.length > 0) { %>,
exclude: [<%= wiredepExclusions.join(', ') %>]
<% } %>
};

return gulp.src(options.src + '/*.html')
.pipe($.inject(injectStyles, injectOptions))
.pipe($.inject(injectScripts, injectOptions))
.pipe(wiredep(wiredepOptions))
.pipe(wiredep(options.wiredep))
.pipe(gulp.dest(options.tmp + '/serve'));

});
Expand Down
36 changes: 21 additions & 15 deletions app/templates/gulp/_styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var browserSync = require('browser-sync');

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

var wiredep = require('wiredep').stream;

module.exports = function(options) {
gulp.task('styles', function () {
<% if (props.cssPreprocessor.key === 'less') { %>
Expand Down Expand Up @@ -37,6 +39,7 @@ module.exports = function(options) {
};

var indexFilter = $.filter('index.<%= props.cssPreprocessor.extension %>');
var vendorFilter = $.filter('vendor.<%= props.cssPreprocessor.extension %>');
<% if (props.cssPreprocessor.key === 'ruby-sass') { %>
var cssFilter = $.filter('**/*.css');
<% } %>
Expand All @@ -45,28 +48,31 @@ module.exports = function(options) {
options.src + '/app/index.<%= props.cssPreprocessor.extension %>',
options.src + '/app/vendor.<%= props.cssPreprocessor.extension %>'
])
.pipe(indexFilter)
.pipe($.inject(injectFiles, injectOptions))
.pipe(indexFilter.restore())
.pipe(indexFilter)
.pipe($.inject(injectFiles, injectOptions))
.pipe(indexFilter.restore())
.pipe(vendorFilter)
.pipe(wiredep(options.wiredep))
.pipe(vendorFilter.restore())
<% if (props.cssPreprocessor.key === 'ruby-sass') { %>
.pipe($.rubySass(sassOptions)).on('error', options.errorHandler('RubySass'))
.pipe(cssFilter)
.pipe($.sourcemaps.init({ loadMaps: true }))
.pipe($.rubySass(sassOptions)).on('error', options.errorHandler('RubySass'))
.pipe(cssFilter)
.pipe($.sourcemaps.init({ loadMaps: true }))
<% } else { %>
.pipe($.sourcemaps.init())
.pipe($.sourcemaps.init())
<% } if (props.cssPreprocessor.key === 'less') { %>
.pipe($.less(lessOptions)).on('error', options.errorHandler('Less'))
.pipe($.less(lessOptions)).on('error', options.errorHandler('Less'))
<% } else if (props.cssPreprocessor.key === 'node-sass') { %>
.pipe($.sass(sassOptions)).on('error', options.errorHandler('Sass'))
.pipe($.sass(sassOptions)).on('error', options.errorHandler('Sass'))
<% } else if (props.cssPreprocessor.key === 'stylus') { %>
.pipe($.stylus()).on('error', options.errorHandler('Stylus'))
.pipe($.stylus()).on('error', options.errorHandler('Stylus'))
<% } %>
.pipe($.autoprefixer()).on('error', options.errorHandler('Autoprefixer'))
.pipe($.sourcemaps.write())
.pipe($.autoprefixer()).on('error', options.errorHandler('Autoprefixer'))
.pipe($.sourcemaps.write())
<% if (props.cssPreprocessor.key === 'ruby-sass') { %>
.pipe(cssFilter.restore())
.pipe(cssFilter.restore())
<% } %>
.pipe(gulp.dest(options.tmp + '/serve/app/'))
.pipe(browserSync.reload({ stream: true }));
.pipe(gulp.dest(options.tmp + '/serve/app/'))
.pipe(browserSync.reload({ stream: true }));
});
};
7 changes: 2 additions & 5 deletions app/templates/gulp/_unit-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ var _ = require('lodash');

module.exports = function(options) {
function listFiles(callback) {
var bowerDeps = wiredep({
directory: 'bower_components',
<% if(wiredepExclusions.length > 0) { %>
exclude: [<%= wiredepExclusions.join(', ') %>],
<% } %>
var wiredepOptions = _.extend({}, options.wiredep, {
dependencies: true,
devDependencies: true
});
var bowerDeps = wiredep(wiredepOptions);

var specFiles = [
options.src + '/**/*.spec.js',
Expand Down
6 changes: 2 additions & 4 deletions app/templates/src/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->

<!-- build:css({<%= props.paths.tmp %>/serve,<%= props.paths.src %>}) styles/vendor.css -->
<% if (isVendorStylesPreprocessed) { %>
<% if (props.cssPreprocessor.key !== 'none') { %>
<link rel="stylesheet" href="app/vendor.css">
<% } else if (props.ui.key === 'bootstrap') { %>
<link rel="stylesheet" href="<%= computedPaths.appToBower %>/bower_components/bootstrap/dist/css/bootstrap.css">
<% } %>
<% } %>
<!-- bower:css -->
<!-- run `gulp inject` to automatically populate bower styles dependencies -->
<!-- endbower -->
Expand Down
3 changes: 0 additions & 3 deletions app/templates/src/app/__bootstrap-vendor.less

This file was deleted.

3 changes: 0 additions & 3 deletions app/templates/src/app/__bootstrap-vendor.scss

This file was deleted.

1 change: 0 additions & 1 deletion app/templates/src/app/__foundation-vendor.scss

This file was deleted.

1 change: 0 additions & 1 deletion app/templates/src/app/__none-vendor.less

This file was deleted.

1 change: 0 additions & 1 deletion app/templates/src/app/__none-vendor.scss

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ section.jumbotron {
}
}
}

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your less files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ section.jumbotron {
}
}
}

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your sass files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ section
&.pull-right
float right
width 50px

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your stylus files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
less dependencies when defined in the bower.json of your dependencies */
// bower:less
// endbower
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
sass dependencies when defined in the bower.json of your dependencies */
// bower:scss
// endbower
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
stylus dependencies when defined in the bower.json of your dependencies */
// bower:styl
// endbower
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
width: 50px;
}
}

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your less files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
width: 50px;
}
}

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your sass files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@

img.pull-right
width 50px

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your stylus files automatically */
// injector
// endinjector
6 changes: 6 additions & 0 deletions app/templates/src/app/_bootstrap/__bootstrap-vendor.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
less dependencies when defined in the bower.json of your dependencies */
// bower:less
// endbower

@icon-font-path: '../<%= computedPaths.appToBower %>/bower_components/bootstrap/fonts/';
6 changes: 6 additions & 0 deletions app/templates/src/app/_bootstrap/__bootstrap-vendor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$icon-font-path: "../<%= computedPaths.appToBower %>/bower_components/bootstrap-sass-official/assets/fonts/bootstrap/";

/* Do not remove this comments bellow. It's the markers used by wiredep to inject
sass dependencies when defined in the bower.json of your dependencies */
// bower:scss
// endbower
4 changes: 4 additions & 0 deletions app/templates/src/app/_bootstrap/__bootstrap-vendor.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
stylus dependencies when defined in the bower.json of your dependencies */
// bower:styl
// endbower
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
width: 50px;
}
}

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your less files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
width: 50px;
}
}

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your sass files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@

img.right
width 50px

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your stylus files automatically */
// injector
// endinjector
4 changes: 4 additions & 0 deletions app/templates/src/app/_foundation/__foundation-vendor.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
less dependencies when defined in the bower.json of your dependencies */
// bower:less
// endbower
8 changes: 8 additions & 0 deletions app/templates/src/app/_foundation/__foundation-vendor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* The import of foundation is made manually because there is still no links of the
sass version in theit bower.json... */
@import '../<%= computedPaths.appToBower %>/bower_components/foundation/scss/foundation';

/* Do not remove this comments bellow. It's the markers used by wiredep to inject
sass dependencies when defined in the bower.json of your dependencies */
// bower:scss
// endbower
4 changes: 4 additions & 0 deletions app/templates/src/app/_foundation/__foundation-vendor.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
stylus dependencies when defined in the bower.json of your dependencies */
// bower:styl
// endbower
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@ a {
hr {
clear: both;
}

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your less files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,8 @@ a {
hr {
clear: both;
}

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your sass files automatically */
// injector
// endinjector
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,8 @@ a

hr
clear both

/* Do not remove this comments bellow. It's the markers used by gulp-inject to inject
all your stylus files automatically */
// injector
// endinjector
4 changes: 4 additions & 0 deletions app/templates/src/app/_none/__none-vendor.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
less dependencies when defined in the bower.json of your dependencies */
// bower:less
// endbower
4 changes: 4 additions & 0 deletions app/templates/src/app/_none/__none-vendor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
sass dependencies when defined in the bower.json of your dependencies */
// bower:scss
// endbower
4 changes: 4 additions & 0 deletions app/templates/src/app/_none/__none-vendor.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Do not remove this comments bellow. It's the markers used by wiredep to inject
stylus dependencies when defined in the bower.json of your dependencies */
// bower:styl
// endbower
4 changes: 2 additions & 2 deletions test/node/test-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ describe('gulp-angular generator techs script', function () {
ui: { key: 'testUi' },
jsPreprocessor: { extension: 'testExtension' }
};
read.withArgs('template/src/app/__ngroute.testExtension')
read.withArgs('template/src/app/_ngroute/__ngroute.testExtension')
.returns('my test content 1');
generator.computeRouter();
generator.routerHtml.should.match(/ng-view/);
generator.routerJs.should.equal('my test content 1');

generator.props.router.module = 'ui.router';
read.withArgs('template/src/app/__uirouter.testExtension')
read.withArgs('template/src/app/_uirouter/__uirouter.testExtension')
.returns('my test content 2');
generator.computeRouter();
generator.routerHtml.should.match(/ui-view/);
Expand Down
Loading