mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
chore(gulpfile): organize tasks
This commit is contained in:
632
gulpfile.js
632
gulpfile.js
@ -61,7 +61,28 @@ var babelOptions = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('build', ['bundle.system', 'e2e.build', 'sass', 'fonts']);
|
/**
|
||||||
|
* Build Ionic sources to dist
|
||||||
|
*/
|
||||||
|
gulp.task('build', function(done){
|
||||||
|
runSequence(
|
||||||
|
'clean',
|
||||||
|
'copy.libs',
|
||||||
|
['bundle', 'sass', 'fonts', 'copy.scss']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build Ionic sources, with typechecking and debug statements removed
|
||||||
|
*/
|
||||||
|
gulp.task('build.release', function(done){
|
||||||
|
IS_RELEASE = true;
|
||||||
|
runSequence(
|
||||||
|
'clean',
|
||||||
|
'copy.libs',
|
||||||
|
['bundle', 'sass', 'fonts', 'copy.scss']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('watch', function(done) {
|
gulp.task('watch', function(done) {
|
||||||
runSequence(
|
runSequence(
|
||||||
@ -125,63 +146,9 @@ gulp.task('clean', function(done) {
|
|||||||
del(['dist/**', '!dist'], done);
|
del(['dist/**', '!dist'], done);
|
||||||
});
|
});
|
||||||
|
|
||||||
function tsCompile(options, cacheName){
|
/**
|
||||||
return gulp.src([
|
* Source build tasks
|
||||||
'ionic/**/*.ts',
|
*/
|
||||||
'!ionic/**/*.d.ts',
|
|
||||||
'!ionic/components/*/test/**/*',
|
|
||||||
'!ionic/util/test/*',
|
|
||||||
'!ionic/config/test/*',
|
|
||||||
'!ionic/platform/test/*',
|
|
||||||
'!ionic/**/*.spec.ts'
|
|
||||||
])
|
|
||||||
.pipe(cache(cacheName, { optimizeMemory: true }))
|
|
||||||
.pipe(tsc(options, undefined, tscReporter))
|
|
||||||
.on('error', function(error) {
|
|
||||||
console.log(error.message);
|
|
||||||
this.emit('end');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task('transpile', function(){
|
|
||||||
var gulpif = require('gulp-if');
|
|
||||||
var stripDebug = require('gulp-strip-debug');
|
|
||||||
|
|
||||||
var tscOpts = getTscOptions(IS_RELEASE ? 'typecheck' : undefined);
|
|
||||||
var tsResult = tsCompile(tscOpts, 'transpile')
|
|
||||||
|
|
||||||
if (IS_RELEASE) {
|
|
||||||
var merge = require('merge2');
|
|
||||||
var js = tsResult.js.pipe(stripDebug());
|
|
||||||
var dts = tsResult.dts;
|
|
||||||
// merge definition and source streams
|
|
||||||
return merge([js, dts])
|
|
||||||
.pipe(gulp.dest('dist'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return tsResult.pipe(gulp.dest('dist'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('bundle.system', function(){
|
|
||||||
var babel = require('gulp-babel');
|
|
||||||
var concat = require('gulp-concat');
|
|
||||||
var gulpif = require('gulp-if');
|
|
||||||
var stripDebug = require('gulp-strip-debug');
|
|
||||||
var merge = require('merge2');
|
|
||||||
|
|
||||||
var tsResult = tsCompile(getTscOptions('es6'), 'system')
|
|
||||||
.pipe(babel(babelOptions));
|
|
||||||
|
|
||||||
var swiper = gulp.src('ionic/components/slides/swiper-widget.system.js');
|
|
||||||
|
|
||||||
return merge([tsResult, swiper])
|
|
||||||
.pipe(remember('system'))
|
|
||||||
.pipe(gulpif(IS_RELEASE, stripDebug()))
|
|
||||||
.pipe(concat('ionic.system.js'))
|
|
||||||
.pipe(gulp.dest('dist/bundles'))
|
|
||||||
.pipe(connect.reload())
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('bundle', ['bundle.cjs', 'bundle.system']);
|
gulp.task('bundle', ['bundle.cjs', 'bundle.system']);
|
||||||
|
|
||||||
gulp.task('bundle.cjs', ['transpile'], function(done){
|
gulp.task('bundle.cjs', ['transpile'], function(done){
|
||||||
@ -202,42 +169,177 @@ gulp.task('bundle.cjs', ['transpile'], function(done){
|
|||||||
minConfig.output.path + path.sep + minConfig.output.filename
|
minConfig.output.path + path.sep + minConfig.output.filename
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function bundle(args) {
|
||||||
|
var webpack = require('webpack');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
webpack(args.config, function(err, stats){
|
||||||
|
if (args.stats) {
|
||||||
|
var statsOptions = {
|
||||||
|
'colors': true,
|
||||||
|
'modules': false,
|
||||||
|
'chunks': false,
|
||||||
|
'exclude': ['node_module'],
|
||||||
|
'errorDetails': true
|
||||||
|
}
|
||||||
|
console.log(stats.toString(statsOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
args.cb && args.cb();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function finished(){
|
function finished(){
|
||||||
gulp.src(outputPaths)
|
gulp.src(outputPaths)
|
||||||
.pipe(connect.reload())
|
.pipe(connect.reload())
|
||||||
.on('end', done);
|
.on('end', done);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
function bundle(args) {
|
gulp.task('bundle.system', function(){
|
||||||
var webpack = require('webpack');
|
var babel = require('gulp-babel');
|
||||||
var path = require('path');
|
var concat = require('gulp-concat');
|
||||||
|
var gulpif = require('gulp-if');
|
||||||
|
var stripDebug = require('gulp-strip-debug');
|
||||||
|
var merge = require('merge2');
|
||||||
|
|
||||||
webpack(args.config, function(err, stats){
|
var tsResult = tsCompile(getTscOptions('es6'), 'system')
|
||||||
if (args.stats) {
|
.pipe(babel(babelOptions));
|
||||||
var statsOptions = {
|
|
||||||
'colors': true,
|
|
||||||
'modules': false,
|
|
||||||
'chunks': false,
|
|
||||||
'exclude': ['node_module'],
|
|
||||||
'errorDetails': true
|
|
||||||
}
|
|
||||||
console.log(stats.toString(statsOptions));
|
|
||||||
}
|
|
||||||
|
|
||||||
args.cb && args.cb();
|
var swiper = gulp.src('ionic/components/slides/swiper-widget.system.js');
|
||||||
})
|
|
||||||
|
return merge([tsResult, swiper])
|
||||||
|
.pipe(remember('system'))
|
||||||
|
.pipe(gulpif(IS_RELEASE, stripDebug()))
|
||||||
|
.pipe(concat('ionic.system.js'))
|
||||||
|
.pipe(gulp.dest('dist/bundles'))
|
||||||
|
.pipe(connect.reload())
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('transpile', function(){
|
||||||
|
var gulpif = require('gulp-if');
|
||||||
|
var stripDebug = require('gulp-strip-debug');
|
||||||
|
|
||||||
|
var tscOpts = getTscOptions(IS_RELEASE ? 'typecheck' : undefined);
|
||||||
|
var tsResult = tsCompile(tscOpts, 'transpile')
|
||||||
|
|
||||||
|
if (IS_RELEASE) {
|
||||||
|
var merge = require('merge2');
|
||||||
|
var js = tsResult.js.pipe(stripDebug());
|
||||||
|
var dts = tsResult.dts;
|
||||||
|
// merge definition and source streams
|
||||||
|
return merge([js, dts])
|
||||||
|
.pipe(gulp.dest('dist'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return tsResult.pipe(gulp.dest('dist'));
|
||||||
|
});
|
||||||
|
|
||||||
|
function tsCompile(options, cacheName){
|
||||||
|
return gulp.src([
|
||||||
|
'ionic/**/*.ts',
|
||||||
|
'!ionic/**/*.d.ts',
|
||||||
|
'!ionic/components/*/test/**/*',
|
||||||
|
'!ionic/util/test/*',
|
||||||
|
'!ionic/config/test/*',
|
||||||
|
'!ionic/platform/test/*',
|
||||||
|
'!ionic/**/*.spec.ts'
|
||||||
|
])
|
||||||
|
.pipe(cache(cacheName, { optimizeMemory: true }))
|
||||||
|
.pipe(tsc(options, undefined, tscReporter))
|
||||||
|
.on('error', function(error) {
|
||||||
|
console.log(error.message);
|
||||||
|
this.emit('end');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('tests', function() {
|
gulp.task('sass', function() {
|
||||||
return gulp.src('ionic/**/test/**/*.spec.ts')
|
var sass = require('gulp-sass');
|
||||||
.pipe(tsc(getTscOptions(), undefined, tscReporter))
|
var autoprefixer = require('gulp-autoprefixer');
|
||||||
.pipe(rename(function(file) {
|
var minifyCss = require('gulp-minify-css');
|
||||||
var regex = new RegExp(path.sep + 'test(' + path.sep + '|$)');
|
|
||||||
file.dirname = file.dirname.replace(regex, path.sep);
|
gulp.src([
|
||||||
}))
|
'ionic/ionic.ios.scss',
|
||||||
.pipe(gulp.dest('dist/tests'))
|
'ionic/ionic.md.scss',
|
||||||
})
|
'ionic/ionic.scss'
|
||||||
|
])
|
||||||
|
.pipe(sass({
|
||||||
|
includePaths: [__dirname + '/node_modules/ionicons/dist/scss/'],
|
||||||
|
}).on('error', sass.logError)
|
||||||
|
)
|
||||||
|
.pipe(autoprefixer(buildConfig.autoprefixer))
|
||||||
|
.pipe(gulp.dest('dist/bundles/'))
|
||||||
|
.pipe(minifyCss())
|
||||||
|
.pipe(rename({ extname: '.min.css' }))
|
||||||
|
.pipe(gulp.dest('dist/bundles/'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('sass.themes', function() {
|
||||||
|
var sass = require('gulp-sass');
|
||||||
|
var autoprefixer = require('gulp-autoprefixer');
|
||||||
|
|
||||||
|
function buildTheme(mode) {
|
||||||
|
gulp.src([
|
||||||
|
'scripts/e2e/ionic.' + mode + '.dark.scss'
|
||||||
|
])
|
||||||
|
.pipe(sass({
|
||||||
|
includePaths: [__dirname + '/node_modules/ionicons/dist/scss/'],
|
||||||
|
}).on('error', sass.logError)
|
||||||
|
)
|
||||||
|
.pipe(autoprefixer(buildConfig.autoprefixer))
|
||||||
|
.pipe(gulp.dest('dist/bundles/'));
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTheme('ios');
|
||||||
|
buildTheme('md');
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('fonts', function() {
|
||||||
|
gulp.src([
|
||||||
|
'ionic/fonts/*.+(ttf|woff|woff2)',
|
||||||
|
'node_modules/ionicons/dist/fonts/*.+(ttf|woff|woff2)'
|
||||||
|
])
|
||||||
|
.pipe(gulp.dest('dist/fonts'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('copy.scss', function() {
|
||||||
|
return gulp.src([
|
||||||
|
'ionic/**/*.scss',
|
||||||
|
'!ionic/components/*/test/**/*',
|
||||||
|
'!ionic/util/test/*'
|
||||||
|
])
|
||||||
|
.pipe(gulp.dest('dist'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('copy.libs', function() {
|
||||||
|
var merge = require('merge2');
|
||||||
|
var webAnimations = gulp.src([
|
||||||
|
'scripts/resources/web-animations-js/web-animations.min.js',
|
||||||
|
'node_modules/es6-shim/es6-shim.min.js',
|
||||||
|
'node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js',
|
||||||
|
'node_modules/systemjs/dist/system.src.js',
|
||||||
|
'node_modules/angular2/bundles/angular2-polyfills.js',
|
||||||
|
'node_modules/angular2/bundles/angular2.dev.js',
|
||||||
|
'node_modules/angular2/bundles/router.dev.js',
|
||||||
|
'node_modules/angular2/bundles/http.dev.js',
|
||||||
|
'node_modules/rxjs/bundles/Rx.js'
|
||||||
|
])
|
||||||
|
.pipe(gulp.dest('dist/js'));
|
||||||
|
|
||||||
|
// for swiper-widget
|
||||||
|
var libs = gulp.src([
|
||||||
|
'ionic/**/*.js',
|
||||||
|
'ionic/**/*.d.ts'
|
||||||
|
])
|
||||||
|
.pipe(gulp.dest('dist'));
|
||||||
|
|
||||||
|
return merge([webAnimations, libs]);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test build tasks
|
||||||
|
*/
|
||||||
|
gulp.task('e2e', ['e2e.build', 'bundle.system', 'copy.libs', 'sass', 'fonts']);
|
||||||
|
|
||||||
gulp.task('e2e.build', function() {
|
gulp.task('e2e.build', function() {
|
||||||
var gulpif = require('gulp-if');
|
var gulpif = require('gulp-if');
|
||||||
@ -324,57 +426,127 @@ gulp.task('e2e.build', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('e2e', ['e2e.build', 'bundle.system', 'copy.libs', 'sass', 'fonts']);
|
gulp.task('tests', function() {
|
||||||
|
return gulp.src('ionic/**/test/**/*.spec.ts')
|
||||||
|
.pipe(tsc(getTscOptions(), undefined, tscReporter))
|
||||||
|
.pipe(rename(function(file) {
|
||||||
|
var regex = new RegExp(path.sep + 'test(' + path.sep + '|$)');
|
||||||
|
file.dirname = file.dirname.replace(regex, path.sep);
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest('dist/tests'))
|
||||||
|
})
|
||||||
|
|
||||||
gulp.task('sass', function() {
|
/**
|
||||||
var sass = require('gulp-sass');
|
* Demos
|
||||||
var autoprefixer = require('gulp-autoprefixer');
|
*/
|
||||||
var minifyCss = require('gulp-minify-css');
|
gulp.task('watch.demos', function() {
|
||||||
|
watch('demos/**/*', function() {
|
||||||
|
gulp.start('demos');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
gulp.src([
|
gulp.task('demos', ['bundle.demos'], function() {
|
||||||
'ionic/ionic.ios.scss',
|
var merge = require('merge2');
|
||||||
'ionic/ionic.md.scss',
|
|
||||||
'ionic/ionic.scss'
|
var demosStream = gulp.src([
|
||||||
|
'dist/demos/**/*',
|
||||||
|
'!dist/demos/**/*.scss',
|
||||||
])
|
])
|
||||||
.pipe(sass({
|
.pipe(gulp.dest(docsConfig.docsDest + '/demos/'));
|
||||||
includePaths: [__dirname + '/node_modules/ionicons/dist/scss/'],
|
|
||||||
}).on('error', sass.logError)
|
var cssStream = gulp.src('dist/bundles/**/*.css')
|
||||||
)
|
.pipe(gulp.dest(docsConfig.sitePath + '/dist/bundles'));
|
||||||
.pipe(autoprefixer(buildConfig.autoprefixer))
|
|
||||||
.pipe(gulp.dest('dist/bundles/'))
|
return merge([demosStream, cssStream]);
|
||||||
.pipe(minifyCss())
|
});
|
||||||
.pipe(rename({ extname: '.min.css' }))
|
|
||||||
.pipe(gulp.dest('dist/bundles/'));
|
gulp.task('bundle.demos', ['build.demos', 'transpile', 'copy.libs', 'sass', 'fonts'], function(done) {
|
||||||
|
var glob = require('glob');
|
||||||
|
var webpack = require('webpack');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
return glob('dist/demos/**/index.js', function(err, files){
|
||||||
|
var numTasks = files.length;
|
||||||
|
files.forEach(function(file){
|
||||||
|
var config = require('./scripts/demos/webpack.config.js');
|
||||||
|
|
||||||
|
// add our bundle entry, removing previous if necessary
|
||||||
|
// since config is cached
|
||||||
|
if (config.entry.length > 4) {
|
||||||
|
config.entry.pop();
|
||||||
|
}
|
||||||
|
config.entry.push('./' + file);
|
||||||
|
config.output = {
|
||||||
|
filename: path.dirname(file) + '/bundle.js'
|
||||||
|
}
|
||||||
|
|
||||||
|
webpack(config, function(err, stats){
|
||||||
|
var statsOptions = {
|
||||||
|
'colors': true,
|
||||||
|
'modules': false,
|
||||||
|
'chunks': false,
|
||||||
|
'exclude': ['node_modules'],
|
||||||
|
'errorDetails': true
|
||||||
|
}
|
||||||
|
console.log(stats.toString(statsOptions));
|
||||||
|
if (--numTasks === 0) done();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('sass.themes', function() {
|
gulp.task('build.demos', function() {
|
||||||
var sass = require('gulp-sass');
|
var gulpif = require('gulp-if');
|
||||||
var autoprefixer = require('gulp-autoprefixer');
|
var merge = require('merge2');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var fs = require('fs');
|
||||||
|
var VinylFile = require('vinyl');
|
||||||
|
|
||||||
function buildTheme(mode) {
|
var baseIndexTemplate = _.template(fs.readFileSync('scripts/demos/index.template.html'))();
|
||||||
gulp.src([
|
|
||||||
'scripts/e2e/ionic.' + mode + '.dark.scss'
|
var tsResult = gulp.src(['demos/**/*.ts'])
|
||||||
|
.pipe(cache('demos.ts'))
|
||||||
|
.pipe(tsc(getTscOptions(), undefined, tscReporter))
|
||||||
|
.on('error', function(error) {
|
||||||
|
console.log(error.message);
|
||||||
|
this.emit('end');
|
||||||
|
})
|
||||||
|
.pipe(gulpif(/index.js$/, createIndexHTML())) //TSC changes .ts to .js
|
||||||
|
|
||||||
|
var demoFiles = gulp.src([
|
||||||
|
'demos/**/*',
|
||||||
|
'!demos/**/*.ts'
|
||||||
])
|
])
|
||||||
.pipe(sass({
|
.pipe(cache('demos.files'));
|
||||||
includePaths: [__dirname + '/node_modules/ionicons/dist/scss/'],
|
|
||||||
}).on('error', sass.logError)
|
return merge([
|
||||||
)
|
tsResult,
|
||||||
.pipe(autoprefixer(buildConfig.autoprefixer))
|
demoFiles
|
||||||
.pipe(gulp.dest('dist/bundles/'));
|
])
|
||||||
|
.pipe(gulp.dest('dist/demos'))
|
||||||
|
.pipe(connect.reload());
|
||||||
|
|
||||||
|
function createIndexHTML() {
|
||||||
|
return through2.obj(function(file, enc, next) {
|
||||||
|
var indexTemplate = baseIndexTemplate;
|
||||||
|
var customTemplateFp = file.path.split('/').slice(0, -1).join('/') + '/index.html';
|
||||||
|
if (fs.existsSync(customTemplateFp)) {
|
||||||
|
indexTemplate = _.template(fs.readFileSync(customTemplateFp))();
|
||||||
|
}
|
||||||
|
this.push(new VinylFile({
|
||||||
|
base: file.base,
|
||||||
|
contents: new Buffer(indexTemplate),
|
||||||
|
path: path.join(path.dirname(file.path), 'index.html'),
|
||||||
|
}));
|
||||||
|
next(null, file);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTheme('ios');
|
|
||||||
buildTheme('md');
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('fonts', function() {
|
|
||||||
gulp.src([
|
|
||||||
'ionic/fonts/*.+(ttf|woff|woff2)',
|
|
||||||
'node_modules/ionicons/dist/fonts/*.+(ttf|woff|woff2)'
|
|
||||||
])
|
|
||||||
.pipe(gulp.dest('dist/fonts'));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests
|
||||||
|
*/
|
||||||
require('./scripts/snapshot/snapshot.task')(gulp, argv, buildConfig);
|
require('./scripts/snapshot/snapshot.task')(gulp, argv, buildConfig);
|
||||||
|
|
||||||
gulp.task('karma', ['tests'], function() {
|
gulp.task('karma', ['tests'], function() {
|
||||||
@ -387,69 +559,14 @@ gulp.task('karma-watch', function() {
|
|||||||
return karma.start({ configFile: __dirname + '/scripts/karma/karma-watch.conf.js' })
|
return karma.start({ configFile: __dirname + '/scripts/karma/karma-watch.conf.js' })
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('copy.scss', function() {
|
/**
|
||||||
return gulp.src([
|
* Release
|
||||||
'ionic/**/*.scss',
|
*/
|
||||||
'!ionic/components/*/test/**/*',
|
gulp.task('prerelease', ['prepare', 'build.release'], function(done){
|
||||||
'!ionic/util/test/*'
|
runSequence('package', done);
|
||||||
])
|
|
||||||
.pipe(gulp.dest('dist'));
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('copy.libs', function() {
|
|
||||||
var merge = require('merge2');
|
|
||||||
var webAnimations = gulp.src([
|
|
||||||
'scripts/resources/web-animations-js/web-animations.min.js',
|
|
||||||
'node_modules/es6-shim/es6-shim.min.js',
|
|
||||||
'node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js',
|
|
||||||
'node_modules/systemjs/dist/system.src.js',
|
|
||||||
'node_modules/angular2/bundles/angular2-polyfills.js',
|
|
||||||
'node_modules/angular2/bundles/angular2.dev.js',
|
|
||||||
'node_modules/angular2/bundles/router.dev.js',
|
|
||||||
'node_modules/angular2/bundles/http.dev.js',
|
|
||||||
'node_modules/rxjs/bundles/Rx.js'
|
|
||||||
])
|
|
||||||
.pipe(gulp.dest('dist/js'));
|
|
||||||
|
|
||||||
var libs = gulp.src([
|
|
||||||
'ionic/**/*.js',
|
|
||||||
'ionic/**/*.d.ts'
|
|
||||||
])
|
|
||||||
.pipe(gulp.dest('dist'));
|
|
||||||
|
|
||||||
return merge([webAnimations, libs]);
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('src', function(done) {
|
|
||||||
IS_RELEASE = true;
|
|
||||||
runSequence(
|
|
||||||
'clean',
|
|
||||||
'copy.libs',
|
|
||||||
['bundle', 'sass', 'fonts', 'copy.scss'],
|
|
||||||
done
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('package', function(done){
|
gulp.task('release', ['publish.npm', 'publish.github']);
|
||||||
var _ = require('lodash');
|
|
||||||
var fs = require('fs');
|
|
||||||
var distDir = 'dist';
|
|
||||||
|
|
||||||
gulp.src([
|
|
||||||
'scripts/npm/.npmignore',
|
|
||||||
'scripts/npm/README.md',
|
|
||||||
'*tooling/**/*'
|
|
||||||
])
|
|
||||||
.pipe(gulp.dest(distDir));
|
|
||||||
|
|
||||||
var templateVars = {};
|
|
||||||
var packageJSON = require('./package.json');
|
|
||||||
templateVars.ionicVersion = packageJSON.version;
|
|
||||||
templateVars.angularVersion = packageJSON.dependencies.angular2;
|
|
||||||
var packageTemplate = _.template(fs.readFileSync('scripts/npm/package.json'));
|
|
||||||
fs.writeFileSync(distDir + '/package.json', packageTemplate(templateVars));
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('prepare', function(){
|
gulp.task('prepare', function(){
|
||||||
var execSync = require('child_process').execSync;
|
var execSync = require('child_process').execSync;
|
||||||
@ -493,8 +610,25 @@ gulp.task('prepare', function(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('prerelease', ['prepare', 'src'], function(done){
|
gulp.task('package', function(done){
|
||||||
runSequence('package', done);
|
var _ = require('lodash');
|
||||||
|
var fs = require('fs');
|
||||||
|
var distDir = 'dist';
|
||||||
|
|
||||||
|
gulp.src([
|
||||||
|
'scripts/npm/.npmignore',
|
||||||
|
'scripts/npm/README.md',
|
||||||
|
'*tooling/**/*'
|
||||||
|
])
|
||||||
|
.pipe(gulp.dest(distDir));
|
||||||
|
|
||||||
|
var templateVars = {};
|
||||||
|
var packageJSON = require('./package.json');
|
||||||
|
templateVars.ionicVersion = packageJSON.version;
|
||||||
|
templateVars.angularVersion = packageJSON.dependencies.angular2;
|
||||||
|
var packageTemplate = _.template(fs.readFileSync('scripts/npm/package.json'));
|
||||||
|
fs.writeFileSync(distDir + '/package.json', packageTemplate(templateVars));
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('publish.github', function(done){
|
gulp.task('publish.github', function(done){
|
||||||
@ -545,124 +679,14 @@ gulp.task('publish.npm', function(done) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('release', ['publish.npm', 'publish.github']);
|
/**
|
||||||
|
* Docs
|
||||||
|
*/
|
||||||
require('./scripts/docs/gulp-tasks')(gulp, flags)
|
require('./scripts/docs/gulp-tasks')(gulp, flags)
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
/**
|
||||||
// Demos
|
* Tooling
|
||||||
// todo: move these to scripts/docs/gulp-tasks
|
*/
|
||||||
////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
gulp.task('build.demos', function(){
|
|
||||||
var gulpif = require('gulp-if');
|
|
||||||
var merge = require('merge2');
|
|
||||||
var _ = require('lodash');
|
|
||||||
var fs = require('fs');
|
|
||||||
var VinylFile = require('vinyl');
|
|
||||||
|
|
||||||
var baseIndexTemplate = _.template(fs.readFileSync('scripts/demos/index.template.html'))();
|
|
||||||
|
|
||||||
var tsResult = gulp.src(['demos/**/*.ts'])
|
|
||||||
.pipe(cache('demos.ts'))
|
|
||||||
.pipe(tsc(getTscOptions(), undefined, tscReporter))
|
|
||||||
.on('error', function(error) {
|
|
||||||
console.log(error.message);
|
|
||||||
this.emit('end');
|
|
||||||
})
|
|
||||||
.pipe(gulpif(/index.js$/, createIndexHTML())) //TSC changes .ts to .js
|
|
||||||
|
|
||||||
var demoFiles = gulp.src([
|
|
||||||
'demos/**/*',
|
|
||||||
'!demos/**/*.ts'
|
|
||||||
])
|
|
||||||
.pipe(cache('demos.files'));
|
|
||||||
|
|
||||||
return merge([
|
|
||||||
tsResult,
|
|
||||||
demoFiles
|
|
||||||
])
|
|
||||||
.pipe(gulp.dest('dist/demos'))
|
|
||||||
.pipe(connect.reload());
|
|
||||||
|
|
||||||
function createIndexHTML() {
|
|
||||||
return through2.obj(function(file, enc, next) {
|
|
||||||
var indexTemplate = baseIndexTemplate;
|
|
||||||
var customTemplateFp = file.path.split('/').slice(0, -1).join('/') + '/index.html';
|
|
||||||
if (fs.existsSync(customTemplateFp)) {
|
|
||||||
indexTemplate = _.template(fs.readFileSync(customTemplateFp))();
|
|
||||||
}
|
|
||||||
this.push(new VinylFile({
|
|
||||||
base: file.base,
|
|
||||||
contents: new Buffer(indexTemplate),
|
|
||||||
path: path.join(path.dirname(file.path), 'index.html'),
|
|
||||||
}));
|
|
||||||
next(null, file);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('bundle.demos', ['build.demos', 'transpile', 'copy.libs', 'sass', 'fonts'], function(done) {
|
|
||||||
buildDemoBundle(done);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('demos', ['bundle.demos'], function() {
|
|
||||||
var merge = require('merge2');
|
|
||||||
|
|
||||||
var demosStream = gulp.src([
|
|
||||||
'dist/demos/**/*',
|
|
||||||
'!dist/demos/**/*.scss',
|
|
||||||
])
|
|
||||||
.pipe(gulp.dest(docsConfig.docsDest + '/demos/'));
|
|
||||||
|
|
||||||
var cssStream = gulp.src('dist/bundles/**/*.css')
|
|
||||||
.pipe(gulp.dest(docsConfig.sitePath + '/dist/bundles'));
|
|
||||||
|
|
||||||
return merge([demosStream, cssStream]);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('watch.demos', function() {
|
|
||||||
watch('demos/**/*', function() {
|
|
||||||
gulp.start('demos');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function buildDemoBundle(done) {
|
|
||||||
var glob = require('glob');
|
|
||||||
var webpack = require('webpack');
|
|
||||||
var path = require('path');
|
|
||||||
|
|
||||||
return glob('dist/demos/**/index.js', function(err, files){
|
|
||||||
var numTasks = files.length;
|
|
||||||
files.forEach(function(file){
|
|
||||||
var config = require('./scripts/demos/webpack.config.js');
|
|
||||||
|
|
||||||
// add our bundle entry, removing previous if necessary
|
|
||||||
// since config is cached
|
|
||||||
if (config.entry.length > 4) {
|
|
||||||
config.entry.pop();
|
|
||||||
}
|
|
||||||
config.entry.push('./' + file);
|
|
||||||
config.output = {
|
|
||||||
filename: path.dirname(file) + '/bundle.js'
|
|
||||||
}
|
|
||||||
|
|
||||||
webpack(config, function(err, stats){
|
|
||||||
var statsOptions = {
|
|
||||||
'colors': true,
|
|
||||||
'modules': false,
|
|
||||||
'chunks': false,
|
|
||||||
'exclude': ['node_modules'],
|
|
||||||
'errorDetails': true
|
|
||||||
}
|
|
||||||
console.log(stats.toString(statsOptions));
|
|
||||||
if (--numTasks === 0) done();
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task('tooling', function(){
|
gulp.task('tooling', function(){
|
||||||
gulp.src('*tooling/**/*')
|
gulp.src('*tooling/**/*')
|
||||||
.pipe(gulp.dest('dist'));
|
.pipe(gulp.dest('dist'));
|
||||||
|
Reference in New Issue
Block a user