diff --git a/app/app.js b/app/app.js index 4a84e3d..ee0bfc2 100644 --- a/app/app.js +++ b/app/app.js @@ -1,4 +1,4 @@ -angular.module('healthyGulpAngularApp', ['ui.router']) +angular.module('healthyGulpAngularApp', ['ui.router', 'healthyGulpAngularAppComponents']) .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { @@ -12,4 +12,4 @@ angular.module('healthyGulpAngularApp', ['ui.router']) templateUrl: 'components/home.html' }); - }]); \ No newline at end of file + }]); diff --git a/app/components/demoComponent/demoComponentDirective.js b/app/components/demoComponent/demoComponentDirective.js index 618766e..a9f9a18 100644 --- a/app/components/demoComponent/demoComponentDirective.js +++ b/app/components/demoComponent/demoComponentDirective.js @@ -1,8 +1,12 @@ -angular.module('healthyGulpAngularApp') +try { + module = angular.module('healthyGulpAngularAppComponents'); +} catch (e) { + module = angular.module('healthyGulpAngularAppComponents', []); +} -.directive('demoComponent', [function() { +module.directive('demoComponent', [function() { return { restrict: 'A', templateUrl: 'components/demoComponent/demoComponent.html' }; - }]); \ No newline at end of file + }]); diff --git a/app/components/demoComponent/demoCsComponent.html b/app/components/demoComponent/demoCsComponent.html new file mode 100644 index 0000000..001e3ac --- /dev/null +++ b/app/components/demoComponent/demoCsComponent.html @@ -0,0 +1 @@ +

This is a CoffeScript demo component.

diff --git a/app/components/demoComponent/demoCsComponentDirective.coffee b/app/components/demoComponent/demoCsComponentDirective.coffee new file mode 100644 index 0000000..72d2a19 --- /dev/null +++ b/app/components/demoComponent/demoCsComponentDirective.coffee @@ -0,0 +1,9 @@ +try + module = angular.module 'healthyGulpAngularAppComponents' +catch e + module = angular.module 'healthyGulpAngularAppComponents', [] + +module.directive 'demoCsComponent', [ () -> + restrict: 'A', + templateUrl: 'components/demoComponent/demoCsComponent.html' + ] diff --git a/app/components/demoComponents.js b/app/components/demoComponents.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/app/components/demoComponents.js @@ -0,0 +1 @@ + diff --git a/app/components/home.html b/app/components/home.html index 250ae65..0df8437 100644 --- a/app/components/home.html +++ b/app/components/home.html @@ -3,4 +3,7 @@

-

\ No newline at end of file +

+

+

+

diff --git a/gulpfile.js b/gulpfile.js index 0001e45..73e10dc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,6 +9,7 @@ var Q = require('q'); // == PATH STRINGS ======== var paths = { + coffee_scripts: 'app/**/*.coffee', scripts: 'app/**/*.js', styles: ['./app/**/*.css', './app/**/*.scss'], images: './images/**/*', @@ -38,6 +39,14 @@ pipes.minifiedFileName = function() { }); }; +pipes.compiledAppCS = function() { + return gulp.src(paths.coffee_scripts) + .pipe(plugins.sourcemaps.init()) + .pipe(plugins.coffee({bare: true}) + .on('error', plugins.util.log)) + .pipe(plugins.sourcemaps.write()); +}; + pipes.validatedAppScripts = function() { return gulp.src(paths.scripts) .pipe(plugins.jshint()) @@ -45,15 +54,19 @@ pipes.validatedAppScripts = function() { }; pipes.builtAppScriptsDev = function() { - return pipes.validatedAppScripts() + var compiledAppCS = pipes.compiledAppCS(); + var validatedAppScripts = pipes.validatedAppScripts(); + + return es.merge(compiledAppCS, validatedAppScripts) .pipe(gulp.dest(paths.distDev)); }; pipes.builtAppScriptsProd = function() { var scriptedPartials = pipes.scriptedPartials(); + var compiledAppCS = pipes.compiledAppCS(); var validatedAppScripts = pipes.validatedAppScripts(); - return es.merge(scriptedPartials, validatedAppScripts) + return es.merge(scriptedPartials, validatedAppScripts, compiledAppCS) .pipe(pipes.orderedAppScripts()) .pipe(plugins.sourcemaps.init()) .pipe(plugins.concat('app.min.js')) @@ -97,7 +110,7 @@ pipes.scriptedPartials = function() { .pipe(plugins.htmlhint.failReporter()) .pipe(plugins.htmlmin({collapseWhitespace: true, removeComments: true})) .pipe(plugins.ngHtml2js({ - moduleName: "healthyGulpAngularApp" + moduleName: "healthyGulpAngularAppComponents" })); }; @@ -267,6 +280,12 @@ gulp.task('watch-dev', ['clean-build-app-dev', 'validate-devserver-scripts'], fu .pipe(plugins.livereload()); }); + // watch app coffee scripts + gulp.watch(paths.coffee_scripts, function() { + return pipes.builtAppScriptsDev() + .pipe(plugins.livereload()); + }); + // watch app scripts gulp.watch(paths.scripts, function() { return pipes.builtAppScriptsDev() @@ -306,6 +325,12 @@ gulp.task('watch-prod', ['clean-build-app-prod', 'validate-devserver-scripts'], .pipe(plugins.livereload()); }); + // watch app coffee scripts + gulp.watch(paths.coffee_scripts, function() { + return pipes.builtAppScriptsProd() + .pipe(plugins.livereload()); + }); + // watch app scripts gulp.watch(paths.scripts, function() { return pipes.builtAppScriptsProd() diff --git a/package.json b/package.json index 17c00d3..5d09ee8 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,13 @@ "devDependencies": { "body-parser": "^1.5.2", "bower": "^1.3.1", + "coffee-script": "~1.9", "del": "^1.1.1", "event-stream": "^3.2.2", "express": "^4.7.2", "gulp": "^3.8.10", "gulp-angular-filesort": "^1.0.4", + "gulp-coffee": "~2.3", "gulp-concat": "^2.4.3", "gulp-htmlhint": "0.0.9", "gulp-htmlmin": "^1.0.0", @@ -27,6 +29,7 @@ "gulp-sass": "^1.3.2", "gulp-sourcemaps": "^1.3.0", "gulp-uglify": "^1.1.0", + "gulp-util": "^3.0.6", "jshint-stylish": "^1.0.0", "karma": "^0.10", "karma-junit-reporter": "^0.2.2",