forked from leovo2708/ngx-treeview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
49 lines (46 loc) · 1.27 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
const gulp = require('gulp');
const sass = require('node-sass');
const inlineTemplates = require('gulp-inline-ng2-template');
/**
* Inline templates configuration.
* @see https://github.com/ludohenin/gulp-inline-ng2-template
*/
const INLINE_TEMPLATES = {
SRC: './src/lib/**/*.ts',
DIST: './tmp',
CONFIG: {
base: '/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));
});
/**
* Compile SASS to CSS.
* @see https://github.com/ludohenin/gulp-inline-ng2-template
* @see https://github.com/sass/node-sass
*/
function compileSass(_path, ext, data, callback) {
const compiledCss = sass.renderSync({
data: data,
outputStyle: 'expanded',
importer: function (url, prev, done) {
if (url.startsWith('~')) {
const newUrl = path.join(__dirname, 'node_modules', url.substr(1));
return { file: newUrl };
} else {
return { file: url };
}
}
});
callback(null, compiledCss.css);
}