-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathgulpfile.js
More file actions
82 lines (72 loc) · 2.09 KB
/
gulpfile.js
File metadata and controls
82 lines (72 loc) · 2.09 KB
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
75
76
77
78
79
80
81
82
var gulp = require("gulp");
var ts = require("gulp-typescript");
var tsProject = ts.createProject("tsconfig.json");
var del = require('del'),
flatten = require('gulp-flatten'),
header = require('gulp-header'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
eslint = require("gulp-eslint-new"),
saveLicense = require('uglify-save-license')
sourcemaps = require('gulp-sourcemaps'),
webpack = require('webpack'),
webpackStream = require('webpack-stream'),
webpackConfig = require('./webpack.config')
;
// Build the license comment.
var package = require('./package.json');
var webpackBanner = package.name + " v" + package.version + " | (c) 2019 Microsoft Corporation " + package.license;
var gulpBanner = "/*! " + webpackBanner + " */\n";
gulp.task("compile:ts", function () {
let src = gulp.src(['./src/*.ts']);
webpackConfig.plugins = [
new webpack.BannerPlugin(webpackBanner)
];
return src
.pipe(tsProject())
.pipe(sourcemaps.init())
.pipe(webpackStream(webpackConfig))
.pipe(gulp.dest("dist"));
});
// Add header to distributed files
gulp.task('header', function () {
return gulp.src(['./dist/*.d.ts'])
.pipe(header(gulpBanner))
.pipe(gulp.dest('./dist'));
});
// Minify build files
gulp.task('min', function () {
return gulp.src(['!./dist/*.min.js', './dist/powerbi-report-authoring.js'])
.pipe(uglify({
output: {
comments: saveLicense
}
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./dist/'));
});
// Clean dist folder
gulp.task('clean:dist', function () {
return del([
'./dist/**/*'
]);
});
// Lints all TypeScript
gulp.task('lint:ts', function () {
return gulp.src(['./src/**/*.ts', './test/**/*.ts'])
.pipe(eslint())
.pipe(eslint.format('stylish'));
});
// Keep this last. Order matters.
gulp.task('build',
gulp.series(
'lint:ts',
'clean:dist',
'compile:ts',
'min',
'header',
function (done) { done(); }
)
);