Skip to content

Commit

Permalink
Merge pull request #106 from ox-it/grunt-build
Browse files Browse the repository at this point in the history
Grunt build
  • Loading branch information
ahaith committed Aug 10, 2016
2 parents a5c7a18 + cc70522 commit 3483335
Show file tree
Hide file tree
Showing 168 changed files with 56,219 additions and 173 deletions.
11 changes: 11 additions & 0 deletions .cordova/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lib": {
"www": {
"id": "phonegap",
"version": "3.3.0",
"uri": "https://github.com/ox-it/moxie-js-client"
}
},
"id": "uk.ac.ox.it.mobileoxford",
"name": "MobileOxford"
}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
css/app.css
css/components/*
css/globals/*
css/foundation/*

# Minified JS
app/main-built.js
Expand All @@ -23,3 +24,10 @@ phonegap_build/

# Ruby bundle (recommended in README.md)
.bundle

app/built.js

node_modules/*
www/*
platforms/*
plugins/*
224 changes: 224 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
(function () {
'use strict';
var cordova = require('cordova');

var platforms = [
'ios',
'android@3.7.1'
//add further platforms here
]


module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

// configurable paths
var yeomanConfig = {
app: 'www'
};

try {
yeomanConfig.app = require('./component.json').appPath || yeomanConfig.app;
} catch (e) {
}

var device = {
platform: grunt.option('platform') || '',
family: grunt.option('family') || 'default',
target: grunt.option('target') || 'emulator'
};

grunt.initConfig({
watchfiles: {
all: [
'www/{,*/}*.html',
'www/js/{,*/,*/}*.js',
'www/css/{,*/}*.css',
'www/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'sass/*.scss'
]
},
watch: {
scripts: {
files: [
'www/js/**/*.js',
'www/css/**/*.css'
],
tasks: ['jshint']
},
liveserve: {
options: {
livereload: true,
},
files: ['<%=watchfiles.all %>'],
tasks: ['shell:serveend', 'cordova-prepareserve']
},
liveemulate: {
files: ['<%=watchfiles.all %>'],
tasks: ['cordova-emulate-end', 'cordova-buildemulate']
},
livedevice: {
files: ['<%=watchfiles.all %>'],
tasks: ['cordova-buildrun']
},
styles: {
files: ['<%=watchfiles.all %>'],
tasks: ['compass']
}

},
shell: {
iossimstart: {
command: 'ios-sim launch platforms/ios/build/yoco.app --exit' + (device.family !== 'default' ? ' --family ' + device.family : ''),
options: {
stdout: true
}
},
iossimend: {
command: 'killall -9 "iPhone Simulator"'
},
serveend: {
command: 'killall -9 "cordova serve"'
},
rippleend: {
command: 'killall -9 "cordova ripple"'
}
},

requirejs: {
compile: {
options: {
mainConfigFile: "require.config.js",
name: "app/libs/almond.js",
out: "app/built.js",
include: ['app/main'],
optimize: 'none'
}
}
},
compass: {
dist: {
options: {
config: 'config.rb'
}
}
},
clean: {
src: ["www/*", "!www/config.xml"],
filter: 'isFile'
},
copy: {
main: {
files: [
{
expand: true,
src: [
"app/built.js",
"images/**",
"css/**",
// "fonts/*",
"webfonts/weather-icons/css/weather-icons.min.css",
"webfonts/weather-icons/font/weathericons-regular-webfont.woff",
"webfonts/weather-icons/font/weathericons-regular-webfont.ttf",
"webfonts/font-awesome/css/font-awesome.min.css",
"webfonts/font-awesome/fonts/fontawesome-webfont.woff",
"webfonts/font-awesome/fonts/fontawesome-webfont.ttf",
"config.xml",
],
dest:"www" },
{
src: ["index-phonegap.html"],
dest: "www/index.html"
},
]
},
},
cordovacli: {
options: {
path: '.',
cli: 'cordova',
},
build_ios: {
options: {
command: 'build',
platforms: ['ios']
}
},
build_android: {
options: {
command: 'build',
platforms: ['android']
}
},
ios: {
options: {
command: 'run',
args: ['--device'],
platforms: ['ios']
}
},
android: {
options: {
command: 'run',
args: ['--device'],
platforms: ['android']
}
},
emulate_android: {
options: {
command: 'run',
platforms: ['android']
}
},
emulate_ios: {
options: {
command: 'run',
platforms: ['ios']
}
},
add_platforms: {
options: {
command: 'platform',
action: 'add',
platforms: platforms
}
}
}
});

grunt.registerTask('ios', [
'package',
'cordovacli:build_ios',
'cordovacli:ios'
]);

grunt.registerTask('android', [
'package',
'cordovacli:build_android',
'cordovacli:android'
]);

grunt.registerTask('ios-sim', [
'package',
'cordovacli:build_ios',
'cordovacli:emulate_ios'
]);

grunt.registerTask('android-sim', [
'package',
'cordovacli:build_android',
'cordovacli:emulate_android'
]);


grunt.registerTask('default', ['package']);

grunt.registerTask('package', 'prepare file for building', ['clean', 'requirejs', 'compass', 'copy'])

grunt.registerTask('ci_build', 'build on CI server', ['package'])

grunt.registerTask('platforms', 'cordovacli:add_platforms');

};
}());
2 changes: 1 addition & 1 deletion app/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['jquery', 'backbone', 'underscore', 'core/views/MapBrowseLayout', 'favourites/collections/Favourites', 'favourites/views/FavouriteButtonView', 'today/collections/TodaySettings', 'core/collections/HelpMessages', 'cordova.help'], function($, Backbone, _, MapBrowseLayout, Favourites, FavouriteButtonView, TodaySettings, HelpMessages, cordova) {
define(['jquery', 'backbone', 'underscore', 'app/core/views/MapBrowseLayout', 'app/favourites/collections/Favourites', 'app/favourites/views/FavouriteButtonView', 'app/today/collections/TodaySettings', 'app/core/collections/HelpMessages', 'app/cordova.help'], function($, Backbone, _, MapBrowseLayout, Favourites, FavouriteButtonView, TodaySettings, HelpMessages, cordova) {
var app = {

navigate: _.wrap(Backbone.history.navigate, function(nav, path, options) {
Expand Down

0 comments on commit 3483335

Please sign in to comment.