mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-29 20:13:43 +03:00
Update build tasks
This commit is contained in:
parent
a43d725256
commit
fde3dccf62
|
@ -12,7 +12,7 @@ git checkout @{-1}
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
# build
|
# build
|
||||||
gulp build
|
npm run build-dist
|
||||||
cd demo
|
cd demo
|
||||||
cp -R ../dist/* ./dist/
|
cp -R ../dist/* ./dist/
|
||||||
mkdir -p releases
|
mkdir -p releases
|
||||||
|
|
|
@ -11,26 +11,22 @@ var gulp = require('gulp');
|
||||||
var sass = require('gulp-sass');
|
var sass = require('gulp-sass');
|
||||||
var replace = require('gulp-replace');
|
var replace = require('gulp-replace');
|
||||||
var rename = require('gulp-rename');
|
var rename = require('gulp-rename');
|
||||||
|
var argv = require('yargs').argv;
|
||||||
|
|
||||||
gulp.task('build', function (callback) {
|
gulp.task('build', function (callback) {
|
||||||
|
if (argv.skipRebuild) {
|
||||||
|
console.log('>>> Rebuild skipped')
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
return runSequence(
|
return runSequence(
|
||||||
'clean',
|
'clean',
|
||||||
'bundleProd',
|
'concatPrism',
|
||||||
callback
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('buildDev', function (callback) {
|
|
||||||
return runSequence(
|
|
||||||
'clean',
|
|
||||||
'bundle',
|
'bundle',
|
||||||
|
'concatDeps',
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('bundle', ['concatPrism', 'buildStatic', 'concatDeps']);
|
|
||||||
gulp.task('bundleProd', ['bundle', 'buildStaticMin', 'concatDepsMin']);
|
|
||||||
|
|
||||||
gulp.task('inlineTemplates', ['sass'], function() {
|
gulp.task('inlineTemplates', ['sass'], function() {
|
||||||
return gulp.src(paths.source, { base: './' })
|
return gulp.src(paths.source, { base: './' })
|
||||||
.pipe(replace(/'(.*?\.css)'/g, '\'.tmp/$1\''))
|
.pipe(replace(/'(.*?\.css)'/g, '\'.tmp/$1\''))
|
||||||
|
@ -38,20 +34,20 @@ gulp.task('inlineTemplates', ['sass'], function() {
|
||||||
.pipe(gulp.dest(paths.tmp));
|
.pipe(gulp.dest(paths.tmp));
|
||||||
});
|
});
|
||||||
|
|
||||||
var JS_DEV_DEPS = [
|
var JS_DEPS = argv.prod ? [
|
||||||
'lib/utils/browser-update.js',
|
'lib/utils/browser-update.js',
|
||||||
'node_modules/zone.js/dist/zone.js',
|
'node_modules/zone.js/dist/zone.js',
|
||||||
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
||||||
'node_modules/reflect-metadata/Reflect.js',
|
'node_modules/reflect-metadata/Reflect.js',
|
||||||
'node_modules/babel-polyfill/dist/polyfill.js'
|
'node_modules/babel-polyfill/dist/polyfill.js'
|
||||||
];
|
] : [
|
||||||
|
|
||||||
var JS_DEV_DEPS_MIN = [
|
|
||||||
'lib/utils/browser-update.js',
|
'lib/utils/browser-update.js',
|
||||||
'node_modules/zone.js/dist/zone.min.js',
|
'node_modules/zone.js/dist/zone.min.js',
|
||||||
'node_modules/reflect-metadata/Reflect.js',
|
'node_modules/reflect-metadata/Reflect.js',
|
||||||
'node_modules/babel-polyfill/dist/polyfill.min.js'
|
'node_modules/babel-polyfill/dist/polyfill.min.js'
|
||||||
]
|
];
|
||||||
|
|
||||||
|
var outputFileName = paths.redocBuilt + (argv.prod ? '.min.js' : '.js');
|
||||||
|
|
||||||
gulp.task('sass', function () {
|
gulp.task('sass', function () {
|
||||||
return gulp.src(paths.scss, { base: './' })
|
return gulp.src(paths.scss, { base: './' })
|
||||||
|
@ -60,38 +56,22 @@ gulp.task('sass', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
// concatenate angular2 deps
|
// concatenate angular2 deps
|
||||||
gulp.task('concatDeps', ['buildStatic'], function() {
|
gulp.task('concatDeps', function() {
|
||||||
return concatDeps(JS_DEV_DEPS, paths.redocBuilt + '.js');
|
return gulp.src(JS_DEPS.concat([outputFileName]))
|
||||||
|
.pipe(sourcemaps.init({loadMaps: true}))
|
||||||
|
.pipe(concat(outputFileName))
|
||||||
|
.pipe(sourcemaps.write('.'))
|
||||||
|
.pipe(gulp.dest('.'))
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('concatDepsMin', ['buildStatic'], function() {
|
gulp.task('bundle', ['inlineTemplates'], function bundle(cb) {
|
||||||
return concatDeps(JS_DEV_DEPS_MIN, paths.redocBuilt + '.min.js');
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('buildStatic', ['inlineTemplates'], function(cb) {
|
|
||||||
bundle(paths.redocBuilt + '.js', false, cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('buildStaticMin', ['inlineTemplates'], function(cb) {
|
|
||||||
bundle(paths.redocBuilt + '.min.js', true, cb);
|
|
||||||
});
|
|
||||||
|
|
||||||
function concatDeps(deps, file) {
|
|
||||||
return gulp.src(deps.concat([file]))
|
|
||||||
.pipe(sourcemaps.init({loadMaps: true}))
|
|
||||||
.pipe(concat(file))
|
|
||||||
.pipe(sourcemaps.write('.'))
|
|
||||||
.pipe(gulp.dest('.'))
|
|
||||||
}
|
|
||||||
|
|
||||||
function bundle(outputFile, minify, cb) {
|
|
||||||
fs.existsSync('dist') || fs.mkdirSync('dist');
|
fs.existsSync('dist') || fs.mkdirSync('dist');
|
||||||
var builder = new Builder('./', 'system.config.js');
|
var builder = new Builder('./', 'system.config.js');
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.buildStatic(path.join(paths.tmp, paths.sourceEntryPoint),
|
.buildStatic(path.join(paths.tmp, paths.sourceEntryPoint),
|
||||||
outputFile,
|
outputFileName,
|
||||||
{ format:'umd', sourceMaps: true, lowResSourceMaps: true, minify: minify }
|
{ format:'umd', sourceMaps: !argv.prod, lowResSourceMaps: true, minify: argv.prod }
|
||||||
)
|
)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// wait some time to allow flush
|
// wait some time to allow flush
|
||||||
|
@ -100,7 +80,7 @@ function bundle(outputFile, minify, cb) {
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
cb(new Error(err));
|
cb(new Error(err));
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
gulp.task('concatPrism', function() {
|
gulp.task('concatPrism', function() {
|
||||||
require('../../system.config.js');
|
require('../../system.config.js');
|
||||||
|
@ -129,7 +109,7 @@ gulp.task('concatPrism', function() {
|
||||||
'components/prism-scala.js'
|
'components/prism-scala.js'
|
||||||
].map(file => path.join(prismFolder, file));
|
].map(file => path.join(prismFolder, file));
|
||||||
|
|
||||||
gulp.src(prismFiles)
|
return gulp.src(prismFiles)
|
||||||
.pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js')))
|
.pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js')))
|
||||||
.pipe(gulp.dest('.'))
|
.pipe(gulp.dest('.'))
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ gulp.task('test-server', function (done) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
gulp.task('e2e', ['bundleProd', 'test-server'], function(done) {
|
gulp.task('e2e', ['build', 'test-server'], function(done) {
|
||||||
gulp.src(['tests/e2e/**/*.js'], { read:false })
|
gulp.src(['tests/e2e/**/*.js'], { read:false })
|
||||||
.pipe(gp.protractor({
|
.pipe(gp.protractor({
|
||||||
configFile: './protractor.conf.js'
|
configFile: './protractor.conf.js'
|
||||||
|
|
|
@ -6,7 +6,7 @@ function changed(event) {
|
||||||
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
|
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...');
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('watch', ['buildDev'], function () {
|
gulp.task('watch', ['build'], function () {
|
||||||
gulp.watch([ paths.source ], [ 'bundle', browserSync.reload ]).on('change', changed);
|
gulp.watch([ paths.source ], [ 'bundle', browserSync.reload ]).on('change', changed);
|
||||||
gulp.watch([ paths.html ], [ 'bundle', browserSync.reload]).on('change', changed);
|
gulp.watch([ paths.html ], [ 'bundle', browserSync.reload]).on('change', changed);
|
||||||
gulp.watch([ paths.scss ], [ 'bundle', browserSync.reload]).on('change', changed);
|
gulp.watch([ paths.scss ], [ 'bundle', browserSync.reload]).on('change', changed);
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
"test": "gulp lint && ./build/run_tests.sh",
|
"test": "gulp lint && ./build/run_tests.sh",
|
||||||
"jspm-install": "jspm install",
|
"jspm-install": "jspm install",
|
||||||
"start": "gulp serve",
|
"start": "gulp serve",
|
||||||
"build-dist": "gulp build",
|
"build-dist": "gulp build --prod",
|
||||||
"branch-release": "git reset --hard && branch-release",
|
"branch-release": "git reset --hard && branch-release",
|
||||||
"unit": "gulp test",
|
"unit": "gulp test",
|
||||||
"e2e": "gulp e2e",
|
"e2e": "gulp e2e --prod",
|
||||||
"deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo"
|
"deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -114,6 +114,7 @@
|
||||||
"sinon": "^1.17.2",
|
"sinon": "^1.17.2",
|
||||||
"systemjs-builder": "^0.15.16",
|
"systemjs-builder": "^0.15.16",
|
||||||
"vinyl-paths": "^2.0.0",
|
"vinyl-paths": "^2.0.0",
|
||||||
|
"yargs": "^4.7.1",
|
||||||
"zone.js": "^0.6.12"
|
"zone.js": "^0.6.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user