Skip to content

Commit

Permalink
Merge pull request #62 from mavogel/ionicbeta22-migration
Browse files Browse the repository at this point in the history
Migration for ionic@beta.22
  • Loading branch information
lathonez committed Mar 24, 2016
2 parents 4398038 + 0eb2fe1 commit f2f66d9
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 195 deletions.
7 changes: 7 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<plugin name="cordova-plugin-device" spec="~1.1.1" />
<plugin name="cordova-plugin-console" spec="~1.0.2" />
<plugin name="cordova-plugin-whitelist" spec="~1.2.1" />
<plugin name="cordova-plugin-splashscreen" spec="~3.1.0" />
<plugin name="cordova-plugin-statusbar" spec="~2.1.2" />
<plugin name="ionic-plugin-keyboard" spec="~2.0.1" />
</widget>

169 changes: 36 additions & 133 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,138 +1,41 @@
/******************************************************************************
* Gulpfile
* Be sure to run `npm install` for `gulp` and the following tasks to be
* available from the command line. All tasks are run using `gulp taskName`.
******************************************************************************/
var gulp = require('gulp'),
webpack = require('webpack'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
watch = require('gulp-watch'),
del = require('del');


var IONIC_DIR = "node_modules/ionic-angular/"


/******************************************************************************
* watch
* Build the app and watch for source file changes.
******************************************************************************/
gulp.task('watch', ['sass', 'copy.fonts', 'copy.html'], function(done) {
watch('www/app/**/*.scss', function(){
gulp.start('sass');
});
watch('www/app/**/*.html', function(){
gulp.start('copy.html');
});
bundle(true, done);
});


/******************************************************************************
* build
* Build the app once, without watching for source file changes.
******************************************************************************/
gulp.task('build', ['sass', 'copy.fonts', 'copy.html'], function(done) {
bundle(false, done);
});


/******************************************************************************
* sass
* Convert Sass files to a single bundled CSS file. Uses auto-prefixer
* to automatically add required vendor prefixes when needed.
******************************************************************************/
gulp.task('sass', function(){
var autoprefixerOpts = {
browsers: [
'last 2 versions',
'iOS >= 7',
'Android >= 4',
'Explorer >= 10',
'ExplorerMobile >= 11'
],
cascade: false
};

return gulp.src('app/theme/app.+(ios|md).scss')
.pipe(sass({
includePaths: [
IONIC_DIR,
'node_modules/ionicons/dist/scss'
]
}))
.on('error', function(err){
console.error(err.message);
this.emit('end');
})
.pipe(autoprefixer(autoprefixerOpts))
.pipe(gulp.dest('www/build/css'))
});


/******************************************************************************
* copy.fonts
* Copy Ionic font files to build directory.
******************************************************************************/
gulp.task('copy.fonts', function() {
return gulp.src(IONIC_DIR + 'fonts/**/*.+(ttf|woff|woff2)')
.pipe(gulp.dest('www/build/fonts'));
});


/******************************************************************************
* copy.html
* Copy html files to build directory.
******************************************************************************/
gulp.task('copy.html', function(){
return gulp.src('app/**/*.html')
.pipe(gulp.dest('www/build'));
var gulp = require('gulp'),
gulpWatch = require('gulp-watch'),
del = require('del'),
argv = process.argv;

/**
* Ionic Gulp tasks, for more information on each see
* https://github.com/driftyco/ionic-gulp-tasks
*/
var buildWebpack = require('ionic-gulp-webpack-build');
var buildSass = require('ionic-gulp-sass-build');
var copyHTML = require('ionic-gulp-html-copy');
var copyFonts = require('ionic-gulp-fonts-copy');

gulp.task('watch', ['sass', 'html', 'fonts'], function(){
gulpWatch('app/**/*.scss', function(){ gulp.start('sass'); });
gulpWatch('app/**/*.html', function(){ gulp.start('html'); });
return buildWebpack({ watch: true });
});


/******************************************************************************
* clean
* Delete previous build files.
******************************************************************************/
gulp.task('clean', function(done) {
del(['www/build'], done);
gulp.task('build', ['sass', 'html', 'fonts'], buildWebpack);
gulp.task('sass', buildSass);
gulp.task('html', copyHTML);
gulp.task('fonts', copyFonts);
gulp.task('clean', function(done){
del('www/build', done);
});


/******************************************************************************
* Bundle
* Transpiles source files and bundles them into build directory using webpack.
******************************************************************************/
function bundle(watch, cb) {
// prevent gulp calling done callback more than once when watching
var firstTime = true;

// load webpack config
var config = require('./webpack.config.js');

// https://github.com/webpack/docs/wiki/node.js-api#statstojsonoptions
var statsOptions = {
'colors': true,
'modules': false,
'chunks': false,
'exclude': ['node_modules']
}

var compiler = webpack(config);
if (watch) {
compiler.watch(null, compileHandler);
} else {
compiler.run(compileHandler);
}

function compileHandler(err, stats){
if (firstTime) {
firstTime = false;
cb();
}

// print build stats and errors
console.log(stats.toString(statsOptions));
}
}
/**
* Ionic hooks
* Add ':before' or ':after' to any Ionic project command name to run the specified
* tasks before or after the command.
*/
gulp.task('serve:before', ['watch']);
gulp.task('emulate:before', ['build']);
gulp.task('deploy:before', ['build']);

// we want to 'watch' when livereloading
var shouldWatch = argv.indexOf('-l') > -1 || argv.indexOf('--livereload') > -1;
gulp.task('run:before', [shouldWatch ? 'watch' : 'build']);
54 changes: 0 additions & 54 deletions ionic.config.js

This file was deleted.

6 changes: 6 additions & 0 deletions ionic.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "clicker",
"app_id": "",
"v2": true,
"typescript": true
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"es6-promise": "3.0.2",
"es6-shim": "0.33.13",
"ionic-angular": "2.0.0-beta.3",
"ionic-native": "^1.1.0",
"ionicons": "3.0.0-alpha.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
Expand All @@ -25,6 +26,10 @@
"gulp-typescript": "^2.12.1",
"gulp-util": "^3.0.7",
"gulp-watch": "4.3.5",
"ionic-gulp-fonts-copy": "^1.0.0",
"ionic-gulp-html-copy": "^1.0.0",
"ionic-gulp-sass-build": "^1.0.0",
"ionic-gulp-webpack-build": "^1.0.0",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "^2.4.0",
"karma": "0.13.21",
Expand All @@ -42,7 +47,7 @@
"ts-node": "0.5.5",
"tslint": "3.5.0",
"tslint-eslint-rules": "1.0.1",
"typescript": "1.8.2",
"typescript": "1.8.7",
"typings": "0.7.7",
"webpack": "^1.12.14"
},
Expand Down
2 changes: 1 addition & 1 deletion test/gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ gulp.task('ionic.build', (done: any) => {
gulp.task('test.build', (done: any) => {
runSequence(
['test.lint', 'test.clean'],
['sass', 'copy.fonts', 'copy.html'], // these are hooks into ionic
['sass', 'fonts', 'html'], // these are hooks into ionic
'test.build.typescript',
done
);
Expand Down
9 changes: 3 additions & 6 deletions www/index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ionic</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">

<link ios-href="build/css/app.ios.css" rel="stylesheet">
<link md-href="build/css/app.md.css" rel="stylesheet">
<link wp-href="build/css/app.wp.css" rel="stylesheet">
</head>
<body>

<!-- this Ionic's root component and where the app will load -->
<ion-app></ion-app>

<script src="cordova.js"></script>
<script src="build/js/app.bundle.js"></script>
</body>
</html>
</html>

0 comments on commit f2f66d9

Please sign in to comment.