Skip to content

Commit

Permalink
Add babel task
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Feb 3, 2016
1 parent f09c860 commit fe83dc1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 13 deletions.
1 change: 1 addition & 0 deletions yeoman/.yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"appName": "CollectiveBehaviorFeaturedimage",
"testFramework": "mocha",
"templateFramework": "lodash",
"sassBootstrap": false,
"includeRequireJS": true,
"coffee": false
},
Expand Down
70 changes: 57 additions & 13 deletions yeoman/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ module.exports = function (grunt) {
nospawn: true,
livereload: LIVERELOAD_PORT
},
babel: {
files: [ '<%= yeoman.app %>/scripts/{,*/}*.es6' ],
tasks: [ 'babel:dist' ]
},
babelTest: {
files: [ 'test/spec/{,*/}*.es6' ],
tasks: [ 'babel:test' ]
},
postcss: {
files: ['<%= yeoman.app %>/styles/{,*/}*.scss'],
tasks: ['csscomb', 'postcss']
Expand Down Expand Up @@ -119,8 +127,7 @@ module.exports = function (grunt) {
dist: ['.tmp', '<%= yeoman.dist %>/*'],
server: '.tmp',
aftercopy: [
'<%= yeoman.dist %>/*.html',
'<%= yeoman.app %>/scripts/templates.js'
'<%= yeoman.dist %>/*.html'
]
},
jshint: {
Expand All @@ -143,6 +150,30 @@ module.exports = function (grunt) {
}
}
},
babel: {
options: {
sourceMap: true,
presets: ['es2015']
},
dist: {
files: [ {
expand: true,
cwd: '<%= yeoman.app %>/scripts',
src: '{,*/}*.es6',
dest: '.tmp/scripts',
ext: '.js'
} ]
},
test: {
files: [ {
expand: true,
cwd: 'test/spec',
src: '{,*/}*.es6',
dest: '.tmp/spec',
ext: '.js'
} ]
}
},
csscomb: {
dist: {
expand: true,
Expand Down Expand Up @@ -179,8 +210,12 @@ module.exports = function (grunt) {

modules: [{name: 'main'}],
baseUrl: '<%= yeoman.app %>/scripts',

mainConfigFile: '<%= yeoman.app %>/scripts/main.js', // contains path specifications and nothing else important with respect to config
paths: {
'main': '../../.tmp/scripts/main'
},
keepBuildDir: true,
allowSourceOverwrites: true,
mainConfigFile: '.tmp/scripts/main.js', // contains path specifications and nothing else important with respect to config

dir: '.tmp/scripts',

Expand Down Expand Up @@ -306,19 +341,18 @@ module.exports = function (grunt) {
variable: 'data'
}
},
serve: {
files: {
'.tmp/scripts/templates.js': ['<%= yeoman.app %>/scripts/templates/*.ejs']
}
},
compile: {
files: {
'<%= yeoman.app %>/scripts/templates.js': ['<%= yeoman.app %>/scripts/templates/*.ejs']
'.tmp/scripts/templates.js': ['<%= yeoman.app %>/scripts/templates/*.ejs']
}
}
}
});

grunt.registerTask('createDefaultTemplate', function () {
grunt.file.write('.tmp/scripts/templates.js', 'this.JST = this.JST || {};');
});

grunt.registerTask('server', function (target) {
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
grunt.task.run(['serve' + (target ? ':' + target : '')]);
Expand All @@ -328,7 +362,9 @@ module.exports = function (grunt) {
if (target === 'test') {
return grunt.task.run([
'clean:server',
'jst:serve',
'babel',
'createDefaultTemplate',
'jst',
'postcss',
'connect:test',
'open:test',
Expand All @@ -338,7 +374,9 @@ module.exports = function (grunt) {

grunt.task.run([
'clean:server',
'jst:serve',
'babel:dist',
'createDefaultTemplate',
'jst',
'postcss',
'connect:livereload',
'watch'
Expand All @@ -349,7 +387,9 @@ module.exports = function (grunt) {
isConnected = Boolean(isConnected);
var testTasks = [
'clean:server',
'jst:serve',
'babel',
'createDefaultTemplate',
'jst',
'postcss',
'connect:test',
'mocha'
Expand All @@ -366,6 +406,8 @@ module.exports = function (grunt) {

grunt.registerTask('build', [
'clean:dist',
'babel',
'createDefaultTemplate',
'jst',
'postcss',
'useminPrepare',
Expand All @@ -382,6 +424,8 @@ module.exports = function (grunt) {

grunt.registerTask('dev', [
'clean:dist',
'babel',
'createDefaultTemplate',
'jst',
'postcss',
'useminPrepare',
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions yeoman/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"devDependencies": {
"apache-server-configs": "^2.8.0",
"autoprefixer": "^6.3.1",
"babel-preset-es2015": "^6.3.13",
"connect-livereload": "^0.4.0",
"es6-promise": "^3.0.2",
"grunt": "^0.4.5",
"grunt-babel": "^6.0.0",
"grunt-bower-requirejs": "^1.1.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.0",
Expand Down

0 comments on commit fe83dc1

Please sign in to comment.