forked from MurhafSousli/ngx-sharebuttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
89 lines (72 loc) · 2.24 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const gulp = require('gulp');
const del = require('del');
/** merge2 for parallel tasks */
var merge = require('merge2');
var embedTemplates = require('gulp-inline-ng2-template');
/** Typescript compilter */
const typescript = require('gulp-typescript');
const uglify = require('gulp-uglify');
/** TSLint checker */
const tslint = require('gulp-tslint');
const sourcemaps = require('gulp-sourcemaps');
/** Sass style */
const postcss = require('gulp-postcss');
const sass = require('gulp-sass');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const scss = require('postcss-scss');
const stripInlineComments = require('postcss-strip-inline-comments');
const tsProject = typescript.createProject('tsconfig.json');
const config = {
allSass: 'src/**/*.scss',
allTs: 'src/**/*.ts',
allTsd: 'typings/index.d.ts',
OutputDir: 'dist/'
};
// clean dist directory
gulp.task('clean', function () {
return del(config.OutputDir);
});
// TypeScript compile
gulp.task('compile-ts', ['clean', 'styles'], function () {
var sourceTsFile = [
config.allTs,
config.allTsd
];
var tsResult = gulp.src(sourceTsFile)
.pipe(embedTemplates({base: './src/share'}))
.pipe(sourcemaps.init())
.pipe(typescript(tsProject));
tsResult.js.pipe(uglify())
.pipe(gulp.dest(config.OutputDir));
return merge([
tsResult.dts.pipe(gulp.dest(config.OutputDir)),
tsResult.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.OutputDir))
]);
});
gulp.task('ts-lint', function () {
return gulp.src(config.allTs)
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report())
});
/** Styles Task */
gulp.task('styles', function () {
var processors = [
stripInlineComments,
autoprefixer,
cssnano
];
return gulp.src(config.allSass)
.pipe(sass().on('error', sass.logError))
.pipe(postcss(processors, {syntax: scss}))
.pipe(gulp.dest('src'));
});
gulp.task('watch', function() {
gulp.watch([config.allTs], ['ts-lint', 'compile-ts']);
gulp.watch([config.allSass, config.allHtml], ['styles']);
});
gulp.task('default', ['ts-lint', 'compile-ts']);