forked from microsoftgraph/microsoft-graph-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
69 lines (58 loc) · 1.86 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const gap = require('gulp-append-prepend');
const cleanCSS = require('gulp-clean-css');
const rename = require('gulp-rename');
var license = require('gulp-header-license');
scssFileHeader = `
// THIS FILE IS AUTO GENERATED
// ANY CHANGES WILL BE LOST DURING BUILD
// MODIFY THE .SCSS FILE INSTEAD
import { css } from 'lit-element';
/**
* exports lit-element css
* @export styles
*/
export const styles = [
css\``;
scssFileFooter = '`];';
licenseStr = `/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
`;
versionFile = `${licenseStr}
// THIS FILE IS AUTO GENERATED
// ANY CHANGES WILL BE LOST DURING BUILD
export const PACKAGE_VERSION = '[VERSION]';
`;
function runSass() {
return gulp
.src('src/**/!(shared)*.scss')
.pipe(sass())
.pipe(cleanCSS())
.pipe(gap.prependText(scssFileHeader))
.pipe(gap.appendText(scssFileFooter))
.pipe(rename({ extname: '-css.ts' }))
.pipe(gulp.dest('src/'));
}
function setLicense() {
return gulp
.src(['packages/**/src/**/*.{ts,js,scss}', "!packages/**/generated/**/*"], { base: './' })
.pipe(license(licenseStr))
.pipe(gulp.dest('./'));
}
function setVersion() {
var pkg = require('./package.json');
var fs = require('fs');
fs.writeFileSync('./src/utils/version.ts', versionFile.replace('[VERSION]', pkg.version));
}
gulp.task('sass', runSass);
gulp.task('setLicense', setLicense);
gulp.task('setVersion', async () => setVersion());
gulp.task('watchSass', () => {
runSass();
return gulp.watch('src/**/*.scss', gulp.series('sass'));
});