Skip to content

Commit 8770a9e

Browse files
bz2steren
authored andcommitted
Show demo in browser on npm start (#52)
* Build demo into dist folder This is then a single location for build artefacts. Add gulp-replace as a devDependency to fix up links. * Serve demo out of local http server on start New devDependency http-server which is used to launch a browser window with the demo application.
1 parent e4b3aff commit 8770a9e

4 files changed

Lines changed: 297 additions & 12 deletions

File tree

demo/demo.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<meta charset="utf-8">
45
<meta name="viewport" content="width=device-width, initial-scale=1.0">
56
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
67
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.teal-red.min.css" />
78
<script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script>
8-
9-
<script src="../node_modules/stacktrace-js/dist/stacktrace-with-promises-and-json-polyfills.js"></script>
10-
<script src="../stackdriver-errors.js"></script>
119
</head>
1210

1311
<body>
@@ -71,8 +69,8 @@ <h4>Parameters</h4>
7169
</main>
7270
</div>
7371

74-
75-
<!-- <script src="demo.js"></script> -->
76-
<script src="demo.min.js"></script>
72+
<!-- scripts for stackdriver and demo application -->
73+
<script src="../dist/stackdriver-errors-concat.min.js"></script>
74+
<script src="../demo/demo.js"></script>
7775
</body>
7876
</html>

gulpfile.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
var gulp = require('gulp');
1717
var rename = require('gulp-rename');
18+
var replace = require('gulp-replace');
1819
var uglify = require('gulp-uglify');
1920
var sourcemaps = require('gulp-sourcemaps');
2021
var mochaPhantomJS = require('gulp-mocha-phantomjs');
@@ -53,13 +54,22 @@ gulp.task('dist', function() {
5354
.pipe(gulp.dest(DEST));
5455
});
5556

56-
gulp.task('min-demo', function() {
57+
gulp.task('demo-html', function() {
58+
return gulp.src('demo/demo.html')
59+
.pipe(replace(/..\/dist\//g, ''))
60+
.pipe(replace(/..\/demo\/demo\.js/g, 'demo.min.js'))
61+
.pipe(rename('index.html'))
62+
.pipe(gulp.dest('dist'));
63+
});
64+
65+
gulp.task('demo-js', function() {
5766
return gulp.src('demo/demo.js')
5867
.pipe(sourcemaps.init())
5968
.pipe(uglify())
6069
.pipe(rename({ extname: '.min.js' }))
6170
.pipe(sourcemaps.write('maps'))
62-
.pipe(gulp.dest('demo'));
71+
.pipe(gulp.dest('dist'));
6372
});
6473

6574
gulp.task('default', ['lint', 'test']);
75+
gulp.task('demo', ['dist', 'demo-html', 'demo-js']);

0 commit comments

Comments
 (0)