forked from CuppaLabs/angular2-multiselect-dropdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (62 loc) · 1.83 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
const gulp = require('gulp');
const sass = require('node-sass');
const inlineTemplates = require('gulp-inline-ng2-template');
const exec = require('child_process').exec;
/**
* Inline templates configuration.
* @see https://github.com/ludohenin/gulp-inline-ng2-template
*/
const INLINE_TEMPLATES = {
SRC: './src/lib/src/**/*.ts',
DIST: './tmp/src-inlined',
CONFIG: {
base: '/src/lib/src',
target: 'es6',
useRelativePaths: true,
styleProcessor: compileSass
}
};
/**
* Inline external HTML and SCSS templates into Angular component files.
* @see: https://github.com/ludohenin/gulp-inline-ng2-template
*/
gulp.task('inline-templates', () => {
return gulp.src(INLINE_TEMPLATES.SRC)
.pipe(inlineTemplates(INLINE_TEMPLATES.CONFIG))
.pipe(gulp.dest(INLINE_TEMPLATES.DIST));
});
/**
* Build ESM by running npm task.
* This is a temporary solution until ngc is supported --watch mode.
* @see: https://github.com/angular/angular/issues/12867
*/
gulp.task('build:esm', ['inline-templates'], (callback) => {
exec('npm run ngcompile', function (error, stdout, stderr) {
console.log(stdout, stderr);
callback(error)
});
});
/**
* Implements ESM build watch mode.
* This is a temporary solution until ngc is supported --watch mode.
* @see: https://github.com/angular/angular/issues/12867
*/
gulp.task('build:esm:watch', ['build:esm'], () => {
gulp.watch('src/**/*', ['build:esm']);
});
gulp.task('copy', () => {
return gulp.src(['package.json','LICENSE','README.md'])
.pipe(gulp.dest('dist/'));
});
/**
* Compile SASS to CSS.
* @see https://github.com/ludohenin/gulp-inline-ng2-template
* @see https://github.com/sass/node-sass
*/
function compileSass(path, ext, file, callback) {
let compiledCss = sass.renderSync({
data: file,
outputStyle: 'compressed',
});
callback(null, compiledCss.css);
}