Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

add more complete Less support #959

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
34 changes: 32 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,28 @@ Generator.prototype.askForCompass = function askForCompass() {
}.bind(this));
};

Generator.prototype.askForLess = function askForLess() {
var compass = this.compass;
var cb = this.async();

this.prompt([{
type: 'confirm',
name: 'less',
message: 'Would you like to use Less?',
default: true,
when: function (props) {
return !compass;
}
}], function (props) {
this.less = props.less;

cb();
}.bind(this));
};

Generator.prototype.askForBootstrap = function askForBootstrap() {
var compass = this.compass;
var less = this.less;
var cb = this.async();

this.prompt([{
Expand All @@ -198,9 +218,18 @@ Generator.prototype.askForBootstrap = function askForBootstrap() {
when: function (props) {
return props.bootstrap && compass;
}
}, {
type: 'confirm',
name: 'lessBootstrap',
message: 'Would you like to use the Less version of Bootstrap?',
default: true,
when: function (props) {
return props.bootstrap && less;
}
}], function (props) {
this.bootstrap = props.bootstrap;
this.compassBootstrap = props.compassBootstrap;
this.lessBootstrap = props.lessBootstrap;

cb();
}.bind(this));
Expand Down Expand Up @@ -310,10 +339,11 @@ Generator.prototype.readIndex = function readIndex() {
};

Generator.prototype.bootstrapFiles = function bootstrapFiles() {
var cssFile = 'styles/main.' + (this.compass ? 's' : '') + 'css';
var cssFile = 'styles/main.css';
var mainFile = 'styles/main.' + (this.less ? 'less' : (this.compass ? 's' : '') + 'css');
this.copy(
path.join('app', cssFile),
path.join(this.appPath, cssFile)
path.join(this.appPath, mainFile)
);
};

Expand Down
11 changes: 11 additions & 0 deletions templates/common/app/styles/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<% if (compass) { %>//bower:scss
//endbower<% } else if (less) { %>//bower:less
//endbower<% } %>

.browsehappy {
margin: 0.2em 0;
background: #ccc;
color: #000;
padding: 0.2em 0;
}

/* Space out content a bit */
body {
padding-top: 20px;
Expand Down
91 changes: 0 additions & 91 deletions templates/common/app/styles/main.scss

This file was deleted.

68 changes: 51 additions & 17 deletions templates/common/root/_Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ module.exports = function (grunt) {
compass: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
},<% } else if (less) { %>
less: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.less'],
tasks: ['less:dist', 'autoprefixer']
},<% } else { %>
styles: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.css'],
Expand Down Expand Up @@ -177,11 +181,17 @@ module.exports = function (grunt) {
wiredep: {
app: {
src: ['<%%= yeoman.app %>/index.html'],
ignorePath: /\.\.\//
ignorePath: /\.\.\//<% if (lessBootstrap) { %>,
exclude: ['bootstrap/dist/css/bootstrap.css']<% } %>
}<% if (compass) { %>,
sass: {
src: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
ignorePath: /(\.\.\/){1,2}bower_components\//
}<% } else if (less) { %>,
less: {
src: ['<%%= yeoman.app %>/styles/{,*/}*.less'],
ignorePath: /(\.\.\/){1,2}bower_components\//<% if (!lessBootstrap) { %>,
exclude: ['bootstrap/less/bootstrap.less']<% } %>
}<% } %>
},<% if (coffee) { %>

Expand Down Expand Up @@ -238,6 +248,23 @@ module.exports = function (grunt) {
debugInfo: true
}
}
},<% } else if (less) { %>

// Compiles Less to CSS and generates necessary files if requested
less: {
options: {
compile: true,
paths: ['./bower_components']
},
dist: {
files: [{
expand: true,
cwd: '<%%= yeoman.app %>/styles',
src: '{,*/}*.less',
dest: '.tmp/styles/',
ext: '.css'
}]
}
},<% } %>

// Renames files for browser caching purposes
Expand Down Expand Up @@ -388,42 +415,48 @@ module.exports = function (grunt) {
dest: '<%%= yeoman.dist %>/images',
src: ['generated/*']
}<% if (bootstrap) { %>, {
expand: true,
cwd: '<% if (!compassBootstrap) {
%>bower_components/bootstrap/dist<%
} else {
%>.<%
} %>',
src: '<% if (compassBootstrap) {
%>bower_components/bootstrap-sass-official/assets/fonts/bootstrap<%
} else { %>fonts<% }
%>/*',
expand: true,<% if (compassBootstrap) { %>
cwd: 'bower_components/bootstrap-sass-official/assets',
src: 'fonts/bootstrap/*'<% } else { %>
cwd: 'bower_components/bootstrap/dist',
src: 'fonts/*'<% } %>,
dest: '<%%= yeoman.dist %>'
}<% } %>]
},
}<% if (compassBootstrap || lessBootstrap) { %>,
server: {
expand: true,<% if (compassBootstrap) { %>
cwd: 'bower_components/bootstrap-sass-official/assets',
src: 'fonts/bootstrap/*'<% } else { %>
cwd: 'bower_components/bootstrap/dist',
src: 'fonts/*'<% } %>,
dest: '.tmp',
}<% } %><% if (!compass && !less) { %>,
styles: {
expand: true,
cwd: '<%%= yeoman.app %>/styles',
dest: '.tmp/styles/',
src: '{,*/}*.css'
}
}<% } %>
},

// Run some tasks in parallel to speed up the build process
concurrent: {
server: [<% if (coffee) { %>
'coffee:dist',<% } %><% if (compass) { %>
'compass:server'<% } else { %>
'compass:server'<% } else if (less) { %>
'less:dist'<% } else { %>
'copy:styles'<% } %>
],
test: [<% if (coffee) { %>
'coffee',<% } %><% if (compass) { %>
'compass'<% } else { %>
'compass'<% } else if (less) { %>
'less'<% } else { %>
'copy:styles'<% } %>
],
dist: [<% if (coffee) { %>
'coffee',<% } %><% if (compass) { %>
'compass:dist',<% } else { %>
'compass:dist',<% } else if (less) { %>
'less:dist',<% } else { %>
'copy:styles',<% } %>
'imagemin',
'svgmin'
Expand All @@ -449,7 +482,8 @@ module.exports = function (grunt) {
}

grunt.task.run([
'clean:server',
'clean:server',<% if (compassBootstrap || lessBootstrap) { %>
'copy:server',<% } %>
'wiredep',
'concurrent:server',
'autoprefixer',
Expand Down
3 changes: 2 additions & 1 deletion templates/common/root/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"grunt-concurrent": "^1.0.0",
"grunt-contrib-clean": "^0.6.0",<% if (coffee) { %>
"grunt-contrib-coffee": "^0.12.0",<% } %><% if (compass) { %>
"grunt-contrib-compass": "^1.0.0",<% } %>
"grunt-contrib-compass": "^1.0.0",<% } else if (less) { %>
"grunt-contrib-less": "^0.10.0",<% } %>
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-copy": "^0.7.0",
Expand Down