@@ -37,6 +37,9 @@ You can rebuild swagger-ui on your own to tweak it or just so you can say you di
|
|||||||
2. `npm run build`
|
2. `npm run build`
|
||||||
3. You should see the distribution under the dist folder. Open [`./dist/index.html`](./dist/index.html) to launch Swagger UI in a browser
|
3. You should see the distribution under the dist folder. Open [`./dist/index.html`](./dist/index.html) to launch Swagger UI in a browser
|
||||||
|
|
||||||
|
### Development
|
||||||
|
Use `npm run build` to make a new build and `npm run serve` to start web server that will serve `dist` directory, watches for changes in files and reloads the page.
|
||||||
|
|
||||||
### Build using Docker
|
### Build using Docker
|
||||||
|
|
||||||
To build swagger-ui using a docker container:
|
To build swagger-ui using a docker container:
|
||||||
|
|||||||
34
gulpfile.js
34
gulpfile.js
@@ -12,6 +12,8 @@ var less = require('gulp-less');
|
|||||||
var handlebars = require('gulp-handlebars');
|
var handlebars = require('gulp-handlebars');
|
||||||
var wrap = require('gulp-wrap');
|
var wrap = require('gulp-wrap');
|
||||||
var declare = require('gulp-declare');
|
var declare = require('gulp-declare');
|
||||||
|
var watch = require('gulp-watch');
|
||||||
|
var connect = require('gulp-connect');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clean ups ./dist folder
|
* Clean ups ./dist folder
|
||||||
@@ -31,7 +33,7 @@ function templates() {
|
|||||||
return gulp
|
return gulp
|
||||||
.src(['./src/main/template/**/*'])
|
.src(['./src/main/template/**/*'])
|
||||||
.pipe(handlebars())
|
.pipe(handlebars())
|
||||||
.pipe(wrap('Handlebars.template(/*__DEFINING__*/<%= contents %>)'))
|
.pipe(wrap('Handlebars.template(<%= contents %>)'))
|
||||||
.pipe(declare({
|
.pipe(declare({
|
||||||
namespace: 'Handlebars.templates',
|
namespace: 'Handlebars.templates',
|
||||||
noRedeclare: true, // Avoid duplicate declarations
|
noRedeclare: true, // Avoid duplicate declarations
|
||||||
@@ -64,7 +66,8 @@ gulp.task('dist', ['clean'], function() {
|
|||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(rename({extname: '.min.js'}))
|
.pipe(rename({extname: '.min.js'}))
|
||||||
.on('error', gutil.log)
|
.on('error', gutil.log)
|
||||||
.pipe(gulp.dest('./dist'));
|
.pipe(gulp.dest('./dist'))
|
||||||
|
.pipe(connect.reload());
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -79,14 +82,15 @@ gulp.task('less', ['clean'], function() {
|
|||||||
])
|
])
|
||||||
.pipe(less())
|
.pipe(less())
|
||||||
.on('error', gutil.log)
|
.on('error', gutil.log)
|
||||||
.pipe(gulp.dest('./src/main/html/css/'));
|
.pipe(gulp.dest('./src/main/html/css/'))
|
||||||
|
.pipe(connect.reload());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy lib and html folders
|
* Copy lib and html folders
|
||||||
*/
|
*/
|
||||||
gulp.task('copy', ['clean'], function() {
|
gulp.task('copy', ['less'], function() {
|
||||||
|
|
||||||
// copy JavaScript files inside lib folder
|
// copy JavaScript files inside lib folder
|
||||||
gulp
|
gulp
|
||||||
@@ -101,5 +105,25 @@ gulp.task('copy', ['clean'], function() {
|
|||||||
.on('error', gutil.log)
|
.on('error', gutil.log)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Watch for changes and recompile
|
||||||
|
*/
|
||||||
|
gulp.task('watch', function() {
|
||||||
|
return watch(['./src/**/*.{coffee,js,less}'], function() {
|
||||||
|
gulp.start('default');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('default', ['dist', 'less', 'copy']);
|
/*
|
||||||
|
* Live reload web server of `dist`
|
||||||
|
*/
|
||||||
|
gulp.task('connect', function() {
|
||||||
|
connect.server({
|
||||||
|
root: 'dist',
|
||||||
|
livereload: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
gulp.task('default', ['dist', 'copy']);
|
||||||
|
gulp.task('serve', ['connect', 'watch'])
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
|
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "./node_modules/gulp/bin/gulp.js;",
|
"build": "./node_modules/gulp/bin/gulp.js;",
|
||||||
|
"serve": "./node_modules/gulp/bin/gulp.js serve;",
|
||||||
"test": "./node_modules/gulp/bin/gulp.js; ./node_modules/mocha/bin/mocha src/test/e2e/index.js"
|
"test": "./node_modules/gulp/bin/gulp.js; ./node_modules/mocha/bin/mocha src/test/e2e/index.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -19,7 +20,6 @@
|
|||||||
"readmeFilename": "README.md",
|
"readmeFilename": "README.md",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"swagger-client": "2.1.0-alpha.7",
|
|
||||||
"chai": "^1.10.0",
|
"chai": "^1.10.0",
|
||||||
"cors": "2.1.1",
|
"cors": "2.1.1",
|
||||||
"docco": "0.4.x",
|
"docco": "0.4.x",
|
||||||
@@ -29,16 +29,19 @@
|
|||||||
"gulp-clean": "^0.3.1",
|
"gulp-clean": "^0.3.1",
|
||||||
"gulp-coffee": "^2.2.0",
|
"gulp-coffee": "^2.2.0",
|
||||||
"gulp-concat": "^2.4.3",
|
"gulp-concat": "^2.4.3",
|
||||||
|
"gulp-connect": "^2.2.0",
|
||||||
"gulp-declare": "^0.3.0",
|
"gulp-declare": "^0.3.0",
|
||||||
"gulp-handlebars": "^3.0.1",
|
"gulp-handlebars": "^3.0.1",
|
||||||
"gulp-less": "^2.0.1",
|
"gulp-less": "^2.0.1",
|
||||||
"gulp-rename": "^1.2.0",
|
"gulp-rename": "^1.2.0",
|
||||||
"gulp-uglify": "^1.1.0",
|
"gulp-uglify": "^1.1.0",
|
||||||
"gulp-util": "^3.0.2",
|
"gulp-util": "^3.0.2",
|
||||||
|
"gulp-watch": "^4.1.0",
|
||||||
"gulp-wrap": "^0.10.1",
|
"gulp-wrap": "^0.10.1",
|
||||||
"http-server": "^0.7.4",
|
"http-server": "^0.7.4",
|
||||||
"less": "~1.4.2",
|
"less": "~1.4.2",
|
||||||
"mocha": "^2.1.0",
|
"mocha": "^2.1.0",
|
||||||
"selenium-webdriver": "^2.44.0"
|
"selenium-webdriver": "^2.44.0",
|
||||||
|
"swagger-client": "2.1.0-alpha.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user