mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
extra dry
This commit is contained in:
100
gulpfile.js
100
gulpfile.js
@ -23,6 +23,35 @@ var lazypipe = require('lazypipe');
|
|||||||
var cache = require('gulp-cached');
|
var cache = require('gulp-cached');
|
||||||
var connect = require('gulp-connect');
|
var connect = require('gulp-connect');
|
||||||
|
|
||||||
|
function getBabelOptions(moduleName) {
|
||||||
|
return {
|
||||||
|
optional: ['es7.decorators'],
|
||||||
|
modules: "system",
|
||||||
|
moduleIds: true,
|
||||||
|
getModuleId: function(name) {
|
||||||
|
return moduleName + '/' + name.split('/test').join('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var tscOptions = {
|
||||||
|
target: 'ES6',
|
||||||
|
// Don't use the version of typescript that gulp-typescript depends on, we need 1.5
|
||||||
|
// see https://github.com/ivogabe/gulp-typescript#typescript-version
|
||||||
|
typescript: require('typescript'),
|
||||||
|
allowNonTsExtensions: true,
|
||||||
|
isolatedModules: true,
|
||||||
|
//declaration: true, //generate d.ts files
|
||||||
|
emitDecoratorMetadata: true,
|
||||||
|
experimentalDecorators: true,
|
||||||
|
noEmitOnError: false, // ignore errors
|
||||||
|
rootDir: '.'
|
||||||
|
}
|
||||||
|
var tscReporter = {
|
||||||
|
error: function (error) {
|
||||||
|
console.error(error.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
gulp.task('clean.build', function() {
|
gulp.task('clean.build', function() {
|
||||||
runSequence(
|
runSequence(
|
||||||
@ -91,58 +120,6 @@ gulp.task('clean', function(done) {
|
|||||||
del(['dist/'], done);
|
del(['dist/'], done);
|
||||||
});
|
});
|
||||||
|
|
||||||
var traceurOptions = {
|
|
||||||
annotations: true,
|
|
||||||
types: true,
|
|
||||||
outputLanguage: 'es6'
|
|
||||||
};
|
|
||||||
|
|
||||||
var babelOptions = {
|
|
||||||
optional: ['es7.decorators'],
|
|
||||||
modules: "system",
|
|
||||||
moduleIds: true,
|
|
||||||
getModuleId: function(name) {
|
|
||||||
return "ionic/" + name;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var exampleBabelOptions = {
|
|
||||||
optional: ['es7.decorators'],
|
|
||||||
modules: "system",
|
|
||||||
moduleIds: true,
|
|
||||||
getModuleId: function(name) {
|
|
||||||
return "examples/" + name.split('/test').join('');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var testBabelOptions = {
|
|
||||||
optional: ['es7.decorators'],
|
|
||||||
modules: "system",
|
|
||||||
moduleIds: true,
|
|
||||||
getModuleId: function(name) {
|
|
||||||
return "tests/" + name.split('/test').join('');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var tscOptions = {
|
|
||||||
target: 'ES6',
|
|
||||||
// Don't use the version of typescript that gulp-typescript depends on, we need 1.5
|
|
||||||
// see https://github.com/ivogabe/gulp-typescript#typescript-version
|
|
||||||
typescript: require('typescript'),
|
|
||||||
allowNonTsExtensions: true,
|
|
||||||
isolatedModules: true,
|
|
||||||
//declaration: true, //generate d.ts files
|
|
||||||
emitDecoratorMetadata: true,
|
|
||||||
experimentalDecorators: true,
|
|
||||||
noEmitOnError: false, // ignore errors
|
|
||||||
rootDir: '.'
|
|
||||||
}
|
|
||||||
var tscReporter = {
|
|
||||||
error: function (error) {
|
|
||||||
console.error(error.message);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
gulp.task('transpile', function() {
|
gulp.task('transpile', function() {
|
||||||
var stream = gulp.src(['ionic/**/*.ts', 'ionic/**/*.js', '!ionic/components/*/test/**/*', '!ionic/init.js'])
|
var stream = gulp.src(['ionic/**/*.ts', 'ionic/**/*.js', '!ionic/components/*/test/**/*', '!ionic/init.js'])
|
||||||
.pipe(cache('transpile', { optimizeMemory: true }))
|
.pipe(cache('transpile', { optimizeMemory: true }))
|
||||||
@ -151,7 +128,7 @@ gulp.task('transpile', function() {
|
|||||||
stream.emit('end');
|
stream.emit('end');
|
||||||
})
|
})
|
||||||
.pipe(gulp.dest('dist/js/es6/ionic'))
|
.pipe(gulp.dest('dist/js/es6/ionic'))
|
||||||
.pipe(babel(babelOptions))
|
.pipe(babel(getBabelOptions('ionic')))
|
||||||
.on('error', function (err) {
|
.on('error', function (err) {
|
||||||
console.log("ERROR: " + err.message);
|
console.log("ERROR: " + err.message);
|
||||||
this.emit('end');
|
this.emit('end');
|
||||||
@ -170,18 +147,17 @@ gulp.task('bundle.js', function() {
|
|||||||
gulp.task('tests', function() {
|
gulp.task('tests', function() {
|
||||||
return gulp.src('ionic/components/*/test/*/**/*.spec.ts')
|
return gulp.src('ionic/components/*/test/*/**/*.spec.ts')
|
||||||
.pipe(tsc(tscOptions, null, tscReporter))
|
.pipe(tsc(tscOptions, null, tscReporter))
|
||||||
.pipe(babel(testBabelOptions))
|
.pipe(babel(getBabelOptions('tests')))
|
||||||
.pipe(rename(function(file) {
|
.pipe(rename(function(file) {
|
||||||
file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep)
|
file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep)
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest('dist/tests'))
|
.pipe(gulp.dest('dist/tests'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
gulp.task('examples', function() {
|
gulp.task('examples', function() {
|
||||||
var buildTest = lazypipe()
|
var buildTest = lazypipe()
|
||||||
.pipe(tsc, tscOptions, null, tscReporter)
|
.pipe(tsc, tscOptions, null, tscReporter)
|
||||||
.pipe(babel, exampleBabelOptions)
|
.pipe(babel, getBabelOptions('examples'))
|
||||||
|
|
||||||
// Get each test folder with gulp.src
|
// Get each test folder with gulp.src
|
||||||
return gulp.src(['ionic/components/*/test/*/**/*', '!ionic/components/*/test/*/**/*.spec.ts'])
|
return gulp.src(['ionic/components/*/test/*/**/*', '!ionic/components/*/test/*/**/*.spec.ts'])
|
||||||
@ -225,15 +201,6 @@ gulp.task('examples', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var e2eBabelOptions = {
|
|
||||||
optional: ['es7.decorators'],
|
|
||||||
modules: "system",
|
|
||||||
moduleIds: true,
|
|
||||||
getModuleId: function(name) {
|
|
||||||
return "e2e/" + name.split('/test').join('');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
gulp.task('copy-scripts', function(){
|
gulp.task('copy-scripts', function(){
|
||||||
gulp.src(['scripts/resources/*.js', 'config.js', 'dist/js/ionic.bundle.js',
|
gulp.src(['scripts/resources/*.js', 'config.js', 'dist/js/ionic.bundle.js',
|
||||||
'dist/vendor/web-animations-js/web-animations.min.js'])
|
'dist/vendor/web-animations-js/web-animations.min.js'])
|
||||||
@ -244,7 +211,7 @@ gulp.task('e2e', ['copy-scripts'], function() {
|
|||||||
var buildTest = lazypipe()
|
var buildTest = lazypipe()
|
||||||
//.pipe(traceur, traceurOptions)
|
//.pipe(traceur, traceurOptions)
|
||||||
.pipe(tsc, tscOptions, null, tscReporter)
|
.pipe(tsc, tscOptions, null, tscReporter)
|
||||||
.pipe(babel, e2eBabelOptions)
|
.pipe(babel, getBabelOptions('e2e'))
|
||||||
|
|
||||||
var buildE2ETest = lazypipe()
|
var buildE2ETest = lazypipe()
|
||||||
//.pipe(traceur, traceurOptions)
|
//.pipe(traceur, traceurOptions)
|
||||||
@ -341,7 +308,6 @@ gulp.task('fonts', function() {
|
|||||||
.pipe(gulp.dest('dist/fonts'));
|
.pipe(gulp.dest('dist/fonts'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
gulp.task('vendor', function() {
|
gulp.task('vendor', function() {
|
||||||
return gulp.src(['scripts/vendor/**/*'])
|
return gulp.src(['scripts/vendor/**/*'])
|
||||||
.pipe(gulp.dest('dist/vendor'));
|
.pipe(gulp.dest('dist/vendor'));
|
||||||
|
Reference in New Issue
Block a user