mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
feat(gulp): add demos task
This commit is contained in:
51
gulpfile.js
51
gulpfile.js
@ -19,7 +19,10 @@ function getBabelOptions(moduleName, moduleType) {
|
|||||||
moduleIds: true,
|
moduleIds: true,
|
||||||
getModuleId: function(name) {
|
getModuleId: function(name) {
|
||||||
if (moduleName == "e2e"){
|
if (moduleName == "e2e"){
|
||||||
return name.replace(/\S*\/test\/[^\/]*\//, '');
|
return name.replace(/^.*\/test\/[^\/]*\//, '');
|
||||||
|
}
|
||||||
|
else if (moduleName == "demos"){
|
||||||
|
return name.replace(/^(.*?)\//, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
return moduleName + '/' + name.split('/test').join('');
|
return moduleName + '/' + name.split('/test').join('');
|
||||||
@ -54,6 +57,7 @@ gulp.task('build', function(done) {
|
|||||||
runSequence(
|
runSequence(
|
||||||
'bundle',
|
'bundle',
|
||||||
'e2e',
|
'e2e',
|
||||||
|
'demos',
|
||||||
'sass',
|
'sass',
|
||||||
'fonts',
|
'fonts',
|
||||||
done
|
done
|
||||||
@ -244,19 +248,9 @@ gulp.task('e2e', function() {
|
|||||||
|
|
||||||
function createIndexHTML() {
|
function createIndexHTML() {
|
||||||
return through2.obj(function(file, enc, next) {
|
return through2.obj(function(file, enc, next) {
|
||||||
var self = this;
|
this.push(new VinylFile({
|
||||||
|
|
||||||
var module = path.dirname(file.path)
|
|
||||||
.replace(__dirname, '')
|
|
||||||
.replace('/ionic/components/', 'e2e/')
|
|
||||||
.replace('/test/', '/') +
|
|
||||||
'/index';
|
|
||||||
|
|
||||||
var indexContents = indexTemplate.replace('{{MODULE}}', module);
|
|
||||||
|
|
||||||
self.push(new VinylFile({
|
|
||||||
base: file.base,
|
base: file.base,
|
||||||
contents: new Buffer(indexContents),
|
contents: new Buffer(indexTemplate),
|
||||||
path: path.join(path.dirname(file.path), 'index.html'),
|
path: path.join(path.dirname(file.path), 'index.html'),
|
||||||
}));
|
}));
|
||||||
next(null, file);
|
next(null, file);
|
||||||
@ -359,6 +353,37 @@ gulp.task('src', function(done){
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gulp.task('demos', function(){
|
||||||
|
var gulpif = require('gulp-if');
|
||||||
|
var lazypipe = require('lazypipe');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var fs = require('fs');
|
||||||
|
var VinylFile = require('vinyl');
|
||||||
|
|
||||||
|
var buildTest = lazypipe()
|
||||||
|
.pipe(tsc, tscOptions, null, tscReporter)
|
||||||
|
.pipe(babel, getBabelOptions('demos'))
|
||||||
|
|
||||||
|
var indexTemplate = _.template(fs.readFileSync('scripts/demos/index.template.html'))();
|
||||||
|
|
||||||
|
return gulp.src(['demos/**/*'])
|
||||||
|
.pipe(cache('demos', { optimizeMemory: true }))
|
||||||
|
.pipe(gulpif(/.ts$/, buildTest()))
|
||||||
|
.pipe(gulpif(/index.js$/, createIndexHTML())) //TSC changes .ts to .js
|
||||||
|
.pipe(gulp.dest('dist/demos'))
|
||||||
|
|
||||||
|
function createIndexHTML() {
|
||||||
|
return through2.obj(function(file, enc, next) {
|
||||||
|
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('publish', function(done) {
|
gulp.task('publish', function(done) {
|
||||||
var version = flags.version;
|
var version = flags.version;
|
||||||
var ngVersion = flags.ngVersion;
|
var ngVersion = flags.ngVersion;
|
||||||
|
21
scripts/demos/index.template.html
Normal file
21
scripts/demos/index.template.html
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<!-- https://www.chromium.org/developers/design-documents/chromium-graphics/how-to-get-gpu-rasterization -->
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
|
|
||||||
|
<link href="../../../css/ionic.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<ion-app>
|
||||||
|
<ion-loading-icon></ion-loading-icon>
|
||||||
|
</ion-app>
|
||||||
|
|
||||||
|
<script src="../../../js/ionic.bundle.js"></script>
|
||||||
|
|
||||||
|
<script>System.import("index");</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user