forked from RobinCK/vue-ls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (66 loc) · 1.94 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var gulp = require('gulp');
var babel = require('rollup-plugin-babel');
var rename = require('gulp-rename');
var rollup = require('gulp-rollup');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var http = require('http');
var connect = require('connect');
var serveStatic = require('serve-static');
var nightwatch = require('gulp-nightwatch');
var gutil = require('gulp-util');
var args = require('get-gulp-args')();
var httpServer;
function logger (message) {
gutil.log(gutil.colors.green(message));
}
gulp.task('js', function () {
return gulp.src('./src/index.js')
.pipe(rollup({
allowRealFiles: true,
entry: './src/index.js',
format: 'umd',
moduleName: 'vue-ls',
plugins: [
babel({
babelrc: false,
runtimeHelpers: true,
externalHelpers: false,
exclude: 'node_modules/**',
presets: [['es2015', {'modules': false}]],
plugins: [
'transform-object-assign',
'external-helpers'
]
})
]
}))
.pipe(rename('vue-ls.js'))
.pipe(gulp.dest('./dist'))
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename('vue-ls.min.js'))
.pipe(sourcemaps.write('.', {includeContent: false}))
.pipe(gulp.dest('./dist'))
;
});
gulp.task('http:start', function (done) {
logger('Start http server');
const app = connect().use(serveStatic('./'));
httpServer = http.createServer(app).listen(9000, done);
});
gulp.task('http:stop', function (done) {
httpServer.close();
logger('Shutdown http server');
done();
});
gulp.task('e2e', gulp.series(['http:start'], function () {
var env = args.env || 'phantomjs';
return gulp.src('./build/nightwatch.config.js')
.pipe(nightwatch({
configFile: './build/nightwatch.config.js',
cliArgs: ['--env ' + env]
}));
}));
gulp.task('test', gulp.series(['e2e', 'http:stop']));
gulp.task('default', gulp.parallel('js'));