Skip to content

Commit

Permalink
Finishing beta3 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
lathonez committed Mar 8, 2016
1 parent 40d682c commit 1e9cc11
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 9 deletions.
138 changes: 138 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/******************************************************************************
* 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'));
});


/******************************************************************************
* clean
* Delete previous build files.
******************************************************************************/
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));
}
}
9 changes: 5 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"experimentalDecorators": true
},
"filesGlob": [
"./app/**/*.ts",
"!node_modules/**/*",
"typings/browser.d.ts"
"**/*.ts",
"!node_modules/**/*"
],
"exclude": [
"node_modules"
"node_modules",
"typings/main",
"typings/main.d.ts"
],
"compileOnSave": false,
"atom": {
Expand Down
8 changes: 4 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ module.exports = {
test: /\.ts$/,
loader: 'awesome-typescript',
query: {
'doTypeCheck': true
doTypeCheck: true,
resolveGlobs: false,
externals: ['typings/browser.d.ts']
},
include: path.resolve('app'),
exclude: /node_modules/
Expand All @@ -37,9 +39,7 @@ module.exports = {
]
},
resolve: {
root: [
'app'
],
root: ['app'],
alias: {
'angular2': path.resolve('node_modules/angular2')
},
Expand Down
3 changes: 2 additions & 1 deletion www/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Ionic</title>
Expand All @@ -9,6 +9,7 @@

<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>

Expand Down

0 comments on commit 1e9cc11

Please sign in to comment.