diff --git a/build/tasks/build.js b/build/tasks/build.js
index b51a3e35..c5cd692f 100644
--- a/build/tasks/build.js
+++ b/build/tasks/build.js
@@ -23,8 +23,7 @@ gulp.task('build', function (callback) {
}
return runSequence(
'clean',
- 'tsc',
- 'inlineTemplates',
+ 'transpile',
'bundle',
'concatDeps',
'copyDebug',
@@ -32,6 +31,14 @@ gulp.task('build', function (callback) {
);
});
+gulp.task('transpile', function(cb) {
+ return runSequence(
+ 'tsc',
+ 'inlineTemplates',
+ cb
+ );
+});
+
gulp.task('copyDebug', () => {
if (!argv.prod) {
// copy for be accessible from demo for debug
@@ -39,16 +46,6 @@ gulp.task('copyDebug', () => {
}
});
-gulp.task('rebuild', function(done) {
- return runSequence(
- 'inlineTemplates',
- 'bundle',
- 'concatDeps',
- 'copyDebug',
- done
- );
-});
-
gulp.task('tsc', function() {
exec('tsc -p ./tsconfig.json');
});
@@ -81,7 +78,7 @@ gulp.task('tsc', function() {
// .pipe(gulp.dest(config.tmp));
// }
-gulp.task('inlineTemplates', ['tsc', 'sass'], function() {
+gulp.task('inlineTemplates', ['sass'], function() {
return gulp.src('.tmp/**/*.js', { base: './tmp' })
.pipe(replace(/'(.*?)\.css'/g, '\'$1.scss\''))
.pipe(inlineNg2Template({
@@ -98,14 +95,14 @@ gulp.task('inlineTemplates', ['tsc', 'sass'], function() {
.pipe(gulp.dest(paths.tmp));
});
-function compileSass(ext, file) {
- file = file.replace('../../shared/styles/variables', 'lib/shared/styles/variables');
- file = file.replace('json-schema-common', 'lib/components/JsonSchema/json-schema-common');
- file = file.replace('../../shared/styles/share-link', 'lib/shared/styles/share-link');
- file = file.replace('../JsonSchema/lib/components/JsonSchema/json-schema-common', 'lib/components/JsonSchema/json-schema-common');
- file = file.replace('../../styles/variables', 'lib/shared/styles/variables');
+function compileSass(ext, file, cb) {
+ file = file.replace('../../shared/styles/variables', 'lib/shared/styles/variables');
+ file = file.replace('json-schema-common', 'lib/components/JsonSchema/json-schema-common');
+ file = file.replace('../../shared/styles/share-link', 'lib/shared/styles/share-link');
+ file = file.replace('../JsonSchema/lib/components/JsonSchema/json-schema-common', 'lib/components/JsonSchema/json-schema-common');
+ file = file.replace('../../styles/variables', 'lib/shared/styles/variables');
- return sassCopm.renderSync({data: file}).css;
+ cb(null, sassCopm.renderSync({data: file}).css);
}
var JS_DEPS = argv.prod ? [
@@ -116,7 +113,7 @@ var JS_DEPS = argv.prod ? [
]: [
'lib/utils/browser-update.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/babel-polyfill/dist/polyfill.js'
];
@@ -138,7 +135,7 @@ gulp.task('concatDeps', ['concatPrism'], function() {
.pipe(gulp.dest('.'))
});
-gulp.task('bundle', function bundle(done) {
+gulp.task('bundle', ['injectVersionFile'], function bundle(done) {
mkdir('-p', 'dist');
cp('lib/index.js', path.join(paths.tmp, paths.sourceEntryPoint));
var builder = new Builder('./', 'system.config.js');
@@ -188,7 +185,8 @@ gulp.task('concatPrism', function() {
});
// needs inlineTemplates run before to create .tmp/lib folder
-gulp.task('injectVersionFile', ['inlineTemplates'], function() {
+gulp.task('injectVersionFile', function() {
var version = require('../../package.json').version;
- fs.writeFileSync(path.join(paths.tmp, 'lib/version.json'), JSON.stringify(version));
+ var exportStatement = `export var redocVersion = "${version}"`;
+ fs.writeFileSync(path.join(paths.tmp, 'lib/version.js'), exportStatement);
})
diff --git a/build/tasks/test.js b/build/tasks/test.js
index 58270bb3..c572bac5 100644
--- a/build/tasks/test.js
+++ b/build/tasks/test.js
@@ -1,12 +1,21 @@
var gulp = require('gulp');
-
+var runSequence = require('run-sequence');
var Server = require('karma').Server;
var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');
+gulp.task('prepare-test', function(cb) {
+ return runSequence(
+ 'clean',
+ 'transpile',
+ 'concatPrism',
+ 'injectVersionFile',
+ cb
+ );
+})
/**
* Run test once and exit
*/
-gulp.task('test', ['concatPrism', 'inlineTemplates', 'injectVersionFile'], function (done) {
+gulp.task('test', ['prepare-test'], function (done) {
new Server({
configFile: __dirname + '/../../karma.conf.js',
singleRun: true
diff --git a/build/tasks/watch.js b/build/tasks/watch.js
index bf2fc0bf..a0cdcdda 100644
--- a/build/tasks/watch.js
+++ b/build/tasks/watch.js
@@ -7,8 +7,8 @@ function changed(event) {
}
gulp.task('watch', ['build'], function () {
- gulp.watch([ paths.source ], [ 'rebuild', browserSync.reload ]).on('change', changed);
- gulp.watch([ paths.html ], [ 'rebuild', browserSync.reload]).on('change', changed);
- gulp.watch([ paths.scss ], [ 'rebuild', browserSync.reload]).on('change', changed);
+ gulp.watch([ paths.source ], [ 'build', browserSync.reload ]).on('change', changed);
+ gulp.watch([ paths.html ], [ 'build', browserSync.reload]).on('change', changed);
+ gulp.watch([ paths.scss ], [ 'build', browserSync.reload]).on('change', changed);
gulp.watch([ paths.demo ], [ '', browserSync.reload ]).on('change', changed);
});
diff --git a/demo/index.html b/demo/index.html
index 0b3bf995..8f466a01 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -24,6 +24,6 @@
-
+