Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Commit

Permalink
fix bootstrap things
Browse files Browse the repository at this point in the history
Fixes #363
Fixes #366
Fixes #388
  • Loading branch information
eddiemonge committed Jun 20, 2014
1 parent ec601dc commit 6dfe277
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 35 deletions.
43 changes: 25 additions & 18 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,40 +116,47 @@ module.exports = yeoman.generators.Base.extend({

mainStylesheet: function () {
var css = 'main.' + (this.includeSass ? 's' : '') + 'css';
this.copy(css, 'app/styles/' + css);
this.template(css, 'app/styles/' + css);
},
writeIndex: function () {

writeIndex: function () {
this.indexFile = this.readFileAsString(join(this.sourceRoot(), 'index.html'));
this.indexFile = this.engine(this.indexFile, this);

// wire Bootstrap plugins
if (this.includeBootstrap) {
var bs = '../bower_components/bootstrap';
var bs = 'bower_components/bootstrap';
bs += this.includeSass ?
'-sass-official/vendor/assets/javascripts/bootstrap/' : '/js/';
this.indexFile = this.appendScripts(this.indexFile, 'scripts/plugins.js', [
bs + 'affix.js',
bs + 'alert.js',
bs + 'dropdown.js',
bs + 'tooltip.js',
bs + 'modal.js',
bs + 'transition.js',
bs + 'button.js',
bs + 'popover.js',
bs + 'carousel.js',
bs + 'scrollspy.js',
bs + 'collapse.js',
bs + 'tab.js'
]);

this.indexFile = this.appendFiles({
html: this.indexFile,
fileType: 'js',
optimizedPath: 'scripts/plugins.js',
sourceFileList: [
bs + 'affix.js',
bs + 'alert.js',
bs + 'dropdown.js',
bs + 'tooltip.js',
bs + 'modal.js',
bs + 'transition.js',
bs + 'button.js',
bs + 'popover.js',
bs + 'carousel.js',
bs + 'scrollspy.js',
bs + 'collapse.js',
bs + 'tab.js'
],
searchPath: '.'
});
}

this.indexFile = this.appendFiles({
html: this.indexFile,
fileType: 'js',
optimizedPath: 'scripts/main.js',
sourceFileList: ['scripts/main.js'],
searchPath: '{app,.tmp}'
searchPath: ['app', '.tmp']
});
},

Expand Down
30 changes: 24 additions & 6 deletions app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ module.exports = function (grunt) {

// Compiles Sass to CSS and generates necessary files if requested
sass: {
options: {<% if (includeLibSass) { %>
sourceMap: true,
includePaths: ['bower_components']
<% } else { %>
sourcemap: true,
loadPath: 'bower_components'
<% } %>},
dist: {
files: [{
expand: true,
Expand Down Expand Up @@ -229,12 +236,14 @@ module.exports = function (grunt) {
// Automatically inject Bower components into the HTML file
wiredep: {
app: {
ignorePath: new RegExp('^<%%= config.app %>/|../'),
src: ['<%%= config.app %>/index.html']<% if (includeBootstrap) { %>,<% if (includeSass) { %>
exclude: ['bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap.js']<% } else { %>
exclude: ['bower_components/bootstrap/dist/js/bootstrap.js']<% } } %>
}<% if (includeSass) { %>,
sass: {
src: ['<%%= config.app %>/styles/{,*/}*.{scss,sass}']
src: ['<%%= config.app %>/styles/{,*/}*.{scss,sass}'],
ignorePath: /(\.\.\/){1,2}bower_components\//
}<% } %>
},

Expand Down Expand Up @@ -359,11 +368,18 @@ module.exports = function (grunt) {
]
}<% if (includeBootstrap) { %>, {
expand: true,
dot: true,<% if (includeSass) { %>
cwd: 'bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrap/',<% } else { %>
cwd: 'bower_components/bootstrap/dist/fonts/',<% } %>
src: ['*.*'],
dest: '<%%= config.dist %>/fonts'
dot: true,
cwd: '<% if (includeSass) {
%>.<%
} else {
%>bower_components/bootstrap/dist<%
} %>',
src: '<% if (includeSass) {
%>bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrap/*<%
} else {
%>fonts/*<%
} %>',
dest: '<%%= config.dist %>'
}<% } %>]
},
styles: {
Expand Down Expand Up @@ -424,6 +440,7 @@ module.exports = function (grunt) {

grunt.task.run([
'clean:server',
'wiredep',
'concurrent:server',
'autoprefixer',
'connect:livereload',
Expand Down Expand Up @@ -454,6 +471,7 @@ module.exports = function (grunt) {

grunt.registerTask('build', [
'clean:dist',
'wiredep',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
Expand Down
6 changes: 3 additions & 3 deletions app/templates/_bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"private": true,
"dependencies": {<% if (includeBootstrap) { if (includeSass) { %>
"bootstrap-sass-official": "~3.1.0",<% } else { %>
"bootstrap": "~3.0.3",<% }} if (includeModernizr) { %>
"modernizr": "~2.6.2",<% } %>
"jquery": "~1.11.0"
"bootstrap": "~3.1.1",<% }} if (includeModernizr) { %>
"modernizr": "~2.8.2",<% } %>
"jquery": "~1.11.1"
},
"devDependencies": {}
}
10 changes: 5 additions & 5 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="/favicon.ico">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css styles/vendor.css -->
<!-- build:css(.) styles/vendor.css -->
<!-- bower:css -->
<% if (includeBootstrap && !includeSass) { %><link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css"><% } %>
<% if (includeBootstrap && !includeSass) { %><link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"><% } %>
<!-- endbower -->
<!-- endbuild -->
<!-- build:css(.tmp) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild --><% if (includeModernizr) { %>
<!-- build:js scripts/vendor/modernizr.js -->
<script src="../bower_components/modernizr/modernizr.js"></script>
<script src="bower_components/modernizr/modernizr.js"></script>
<!-- endbuild -->
<% } %>
</head>
Expand Down Expand Up @@ -77,9 +77,9 @@ <h1>'Allo, 'Allo!</h1>
</div>
<% } %>

<!-- build:js scripts/vendor.js -->
<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<script src="../bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/jquery/dist/jquery.js"></script>
<!-- endbower -->
<!-- endbuild -->

Expand Down
5 changes: 2 additions & 3 deletions app/templates/main.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<% if (includeBootstrap) { %>$icon-font-path: "../styles/fonts/";

<% if (includeBootstrap) { %>$icon-font-path: "../bower_components/bootstrap-sass-official/vendor/assets/fonts/bootstrap/";
// bower:scss
@import '../../bower_components/bootstrap-sass-official/vendor/assets/stylesheets/bootstrap.scss';
@import "bootstrap-sass-official/vendor/assets/stylesheets/bootstrap.scss";
// endbower

.browsehappy {
Expand Down

3 comments on commit 6dfe277

@silvenon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very brave of you 👍 This doesn't break the build, right?

@KingScooty
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just tried this out on my fork and seems to work perfectly 👍 :)

@eddiemonge
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im going to do a prerelease candidate for widespread testing

Please sign in to comment.