Skip to content

Instantly share code, notes, and snippets.

@bguiz
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bguiz/9042855 to your computer and use it in GitHub Desktop.
Save bguiz/9042855 to your computer and use it in GitHub Desktop.
Add express stub server to Gruntfile (from generator-angular as starting point)
diff --git a/ngyo/Gruntfile.js b/ngyo/Gruntfile.js
index 3df3112..2cb746a 100644
--- a/ngyo/Gruntfile.js
+++ b/ngyo/Gruntfile.js
@@ -1,6 +1,8 @@
// Generated on 2014-02-13 using generator-angular 0.7.1
'use strict';
+var path = require('path');
+
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
@@ -15,15 +17,17 @@ module.exports = function (grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
+ var yoCfg = {
+ // configurable paths
+ app: require('./bower.json').appPath || 'app',
+ dist: 'dist'
+ };
+
// Define the configuration for all the tasks
grunt.initConfig({
// Project settings
- yeoman: {
- // configurable paths
- app: require('./bower.json').appPath || 'app',
- dist: 'dist'
- },
+ yeoman: yoCfg,
// Watches files for changes and runs tasks based on the changed files
watch: {
@@ -44,17 +48,18 @@ module.exports = function (grunt) {
},
gruntfile: {
files: ['Gruntfile.js']
- },
- livereload: {
- options: {
- livereload: '<%= connect.options.livereload %>'
- },
- files: [
- '<%= yeoman.app %>/{,*/}*.html',
- '.tmp/styles/{,*/}*.css',
- '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
- ]
}
+ // ,
+ // livereload: {
+ // options: {
+ // livereload: '<%= connect.options.livereload %>'
+ // },
+ // files: [
+ // '<%= yeoman.app %>/{,*/}*.html',
+ // '.tmp/styles/{,*/}*.css',
+ // '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
+ // ]
+ // }
},
// The actual grunt server settings
@@ -147,9 +152,6 @@ module.exports = function (grunt) {
}
},
-
-
-
// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
@@ -179,7 +181,34 @@ module.exports = function (grunt) {
}
},
- // Renames files for browser caching purposes
+ express: {
+ options: {
+ port: 9000,
+ hostname: '*'
+ },
+ livereload: {
+ options: {
+ server: path.resolve('./server/stub-server'),
+ livereload: true,
+ serverreload: true,
+ bases: [path.resolve('./.tmp'), path.resolve(__dirname, yoCfg.app)]
+ }
+ },
+ test: {
+ options: {
+ server: path.resolve('./server/stub-server'),
+ bases: [path.resolve('./.tmp'), path.resolve(__dirname, 'test')]
+ }
+ },
+ dist: {
+ options: {
+ server: path.resolve('./server/stub-server'),
+ bases: path.resolve(__dirname, yoCfg.dist)
+ }
+ }
+ },
+
+ // Renames files for browser caching purposesl
rev: {
dist: {
files: {
@@ -355,7 +384,7 @@ module.exports = function (grunt) {
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
- return grunt.task.run(['build', 'connect:dist:keepalive']);
+ return grunt.task.run(['build', 'express:dist:keepalive']);
}
grunt.task.run([
@@ -363,7 +392,7 @@ module.exports = function (grunt) {
'bower-install',
'concurrent:server',
'autoprefixer',
- 'connect:livereload',
+ 'express:livereload',
'watch'
]);
});
@@ -377,7 +406,7 @@ module.exports = function (grunt) {
'clean:server',
'concurrent:test',
'autoprefixer',
- 'connect:test',
+ 'express:test',
'karma'
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment