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

feat(gen): add Less support to the initialization process #637

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 30 additions & 2 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,25 @@ 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 cb = this.async();
Expand Down Expand Up @@ -284,10 +303,19 @@ Generator.prototype.readIndex = function readIndex() {
};

Generator.prototype.bootstrapFiles = function bootstrapFiles() {
var cssFile = 'styles/main.' + (this.compass ? 's' : '') + 'css';
var cssFile = 'styles/main.css';
var sass = this.compass;
var mainFile = 'styles/main.';
if (this.less) {
mainFile += 'less';
}
else {
mainFile += (sass ? 's' : '') + 'css';
}

this.copy(
path.join('app', cssFile),
path.join(this.appPath, cssFile)
path.join(this.appPath, mainFile)
);
};

Expand Down
16 changes: 16 additions & 0 deletions templates/common/app/styles/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<% if (bootstrap) { %>
<% if (compassBootstrap) { %>$icon-font-path: "../bower_components/bootstrap-sass-official/assets/fonts/bootstrap/";
// bower:scss
// endbower
<% } else { %>
@import 'bootstrap/less/bootstrap';
<% } %>
<% } %>

.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.

33 changes: 28 additions & 5 deletions templates/common/root/_Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ module.exports = function (grunt) {
compass: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
},<% } else { %>
},<% } else if (less) { %>
less: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.less'],
tasks: ['less:dist', 'autoprefixer']
}, <% } else { %>
styles: {
files: ['<%%= yeoman.app %>/styles/{,*/}*.css'],
tasks: ['newer:copy:styles', 'autoprefixer']
Expand Down Expand Up @@ -241,7 +245,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
filerev: {
Expand Down Expand Up @@ -416,17 +436,20 @@ module.exports = function (grunt) {
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 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": "^0.5.0",
"grunt-contrib-clean": "^0.5.0",<% if (coffee) { %>
"grunt-contrib-coffee": "^0.10.1",<% } %><% if (compass) { %>
"grunt-contrib-compass": "^0.7.2",<% } %>
"grunt-contrib-compass": "^0.7.2",<% } %><% if (less) { %>
"grunt-contrib-less": "^0.10.0",<% } %>
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-copy": "^0.5.0",
Expand Down