mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
chore(build): add gulp watch task for demos
This commit is contained in:
113
gulpfile.js
113
gulpfile.js
@ -30,6 +30,50 @@ function getBabelOptions(moduleName, moduleType) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildDemoBundle(opts, done) {
|
||||||
|
var glob = require('glob');
|
||||||
|
var webpack = require('webpack');
|
||||||
|
var path = require('path');
|
||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
|
var numWebpacks = 0;
|
||||||
|
var fp = 'dist/demos/'+opts.demo+'/index.js';
|
||||||
|
if (opts.demo == '*') {
|
||||||
|
fp = "dist/demos/**/index.js";
|
||||||
|
}
|
||||||
|
|
||||||
|
return glob(fp, function(err, files){
|
||||||
|
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 > 5) {
|
||||||
|
config.entry.pop();
|
||||||
|
}
|
||||||
|
config.entry.push('./' + file);
|
||||||
|
config.output = {
|
||||||
|
filename: path.dirname(file) + '/bundle.js'
|
||||||
|
}
|
||||||
|
|
||||||
|
// pretty sure this is a race, but it works
|
||||||
|
numWebpacks++;
|
||||||
|
webpack(config, function(err, stats){
|
||||||
|
// var statsOptions = {
|
||||||
|
// 'colors': true,
|
||||||
|
// 'modules': true,
|
||||||
|
// 'chunks': false,
|
||||||
|
// 'exclude': ['node_modules'],
|
||||||
|
// 'errorDetails': true
|
||||||
|
// }
|
||||||
|
// console.log(stats.toString(statsOptions));
|
||||||
|
if (--numWebpacks === 0) done();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var tscOptions = {
|
var tscOptions = {
|
||||||
target: 'ES6',
|
target: 'ES6',
|
||||||
allowNonTsExtensions: true,
|
allowNonTsExtensions: true,
|
||||||
@ -59,7 +103,6 @@ gulp.task('build', function(done) {
|
|||||||
runSequence(
|
runSequence(
|
||||||
'bundle',
|
'bundle',
|
||||||
'e2e',
|
'e2e',
|
||||||
// 'demos:all',
|
|
||||||
'sass',
|
'sass',
|
||||||
'fonts',
|
'fonts',
|
||||||
done
|
done
|
||||||
@ -100,10 +143,6 @@ gulp.task('watch', function(done) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// watch('demos/**/*', function() {
|
|
||||||
// gulp.start('demos:all');
|
|
||||||
// });
|
|
||||||
|
|
||||||
watch('ionic/components/*/test/**/*', function(file) {
|
watch('ionic/components/*/test/**/*', function(file) {
|
||||||
if (file.event === "unlink") {
|
if (file.event === "unlink") {
|
||||||
var paths = file.history[0].split("ionic/components/");
|
var paths = file.history[0].split("ionic/components/");
|
||||||
@ -131,6 +170,12 @@ gulp.task('watch', function(done) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('watch:demos', function() {
|
||||||
|
watch('demos/**/*', function() {
|
||||||
|
gulp.start('demos:docs');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('serve', function() {
|
gulp.task('serve', function() {
|
||||||
var connect = require('gulp-connect');
|
var connect = require('gulp-connect');
|
||||||
connect.server({
|
connect.server({
|
||||||
@ -360,11 +405,6 @@ gulp.task('src.link', function(done) {
|
|||||||
watch(['/ionic/**/*.ts', 'ionic/**/*.scss'], function(file) {
|
watch(['/ionic/**/*.ts', 'ionic/**/*.scss'], function(file) {
|
||||||
gulp.start('src');
|
gulp.start('src');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// watch('demos/**/*', function() {
|
|
||||||
// gulp.start('demos:all');
|
|
||||||
// });
|
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('src', function(done){
|
gulp.task('src', function(done){
|
||||||
@ -415,52 +455,29 @@ gulp.task('build.demos', function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('bundle.demos', ['build.demos'], function(done){
|
gulp.task('bundle.demos:all', ['build.demos'], function(done) {
|
||||||
var glob = require('glob');
|
return buildDemoBundle({demo: '*'}, done);
|
||||||
var webpack = require('webpack');
|
|
||||||
var path = require('path');
|
|
||||||
var _ = require('lodash');
|
|
||||||
|
|
||||||
var numWebpacks = 0;
|
|
||||||
glob('dist/demos/**/index.js', function(err, files){
|
|
||||||
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 > 5) {
|
|
||||||
config.entry.pop();
|
|
||||||
}
|
|
||||||
config.entry.push('./' + file);
|
|
||||||
config.output = {
|
|
||||||
filename: path.dirname(file) + '/bundle.js'
|
|
||||||
}
|
|
||||||
|
|
||||||
// pretty sure this is a race, but it works
|
|
||||||
numWebpacks++;
|
|
||||||
webpack(config, function(err, stats){
|
|
||||||
// var statsOptions = {
|
|
||||||
// 'colors': true,
|
|
||||||
// 'modules': true,
|
|
||||||
// 'chunks': false,
|
|
||||||
// 'exclude': ['node_modules'],
|
|
||||||
// 'errorDetails': true
|
|
||||||
// }
|
|
||||||
// console.log(stats.toString(statsOptions));
|
|
||||||
if (--numWebpacks === 0) done();
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('demos', ['bundle.demos']);
|
gulp.task('bundle.demos:docs', ['build.demos'], function(done) {
|
||||||
|
buildDemoBundle({demo: 'component-docs'}, done);
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('demos:all', ['demos'], function() {
|
gulp.task('demos:all', ['bundle.demos:all'], function() {
|
||||||
return gulp
|
return gulp
|
||||||
.src('dist/demos/component-docs/**/*')
|
.src('dist/demos/component-docs/**/*')
|
||||||
.pipe(gulp.dest('dist/ionic-site/docs/v2/components/demo/'))
|
.pipe(gulp.dest('dist/ionic-site/docs/v2/components/demo/'))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('demos:docs', ['bundle.demos:docs'], function() {
|
||||||
|
return gulp
|
||||||
|
.src('dist/demos/component-docs/**/*')
|
||||||
|
.pipe(gulp.dest('dist/ionic-site/docs/v2/components/demo/'))
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('demos', ['demos:all']);
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
Reference in New Issue
Block a user