-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
57 lines (47 loc) · 1.43 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
/* eslint-env node */
const path = require('path');
const {task, src, dest, series} = require('gulp');
const rimraf = require('rimraf');
const ts = require('gulp-typescript');
const replace = require('gulp-replace');
const sass = require('gulp-dart-sass');
const BUILD_DIR = path.resolve('build');
task('clean', (done) => {
rimraf.sync(BUILD_DIR);
rimraf.sync('styles/**/*.css');
done();
});
function compileTs() {
const tsProject = ts.createProject('tsconfig.json', {
declaration: true,
module: 'esnext',
});
return src(['src/**/*.{js,jsx,ts,tsx}'])
.pipe(replace(/import '.+\.scss';/g, (match) => match.replace('.scss', '.css')))
.pipe(tsProject())
.pipe(dest(path.resolve(BUILD_DIR)));
}
task('compile-to-esm', () => {
return compileTs();
});
task('copy-js-declarations', () => {
return src(['src/**/*.d.ts']).pipe(dest(path.resolve(BUILD_DIR)));
});
task('copy-i18n', () => {
return src(['src/**/*.json']).pipe(dest(path.resolve(BUILD_DIR)));
});
task('styles-components', () => {
return src('src/**/*.scss')
.pipe(
sass({
includePaths: ['node_modules'],
}),
)
.pipe(sass().on('error', sass.logError))
.pipe(dest(path.resolve(BUILD_DIR)));
});
task(
'build',
series(['clean', 'compile-to-esm', 'copy-js-declarations', 'copy-i18n', 'styles-components']),
);
task('default', series(['build']));