|
1 |
| -const gulp = require('gulp'); |
2 |
| -const rename = require('gulp-rename'); |
3 |
| -const ts = require('gulp-typescript'); |
4 |
| -const sass = require('gulp-sass'); |
5 |
| -const merge = require('merge2'); |
6 |
| -const tsProject = ts.createProject('./tsconfig.build.json'); |
7 |
| -const webpackStream = require('webpack-stream'); |
| 1 | +const gulp = require("gulp"); |
| 2 | +const rename = require("gulp-rename"); |
| 3 | +const ts = require("gulp-typescript"); |
| 4 | +const sass = require("gulp-sass"); |
| 5 | +const merge = require("merge2"); |
| 6 | +const tsProject = ts.createProject("./tsconfig.build.json"); |
| 7 | +const webpackStream = require("webpack-stream"); |
8 | 8 |
|
9 |
| -gulp.task('build_styles', function () { |
10 |
| - return gulp.src('./src/styles/**/*.scss') |
11 |
| - .pipe(sass().on('error', sass.logError)) |
12 |
| - .pipe(gulp.dest('./lib/styles/css')); |
13 |
| -}); |
| 9 | +function buildStyles() { |
| 10 | + return gulp |
| 11 | + .src("./src/styles/**/*.scss") |
| 12 | + .pipe(sass().on("error", sass.logError)) |
| 13 | + .pipe(gulp.dest("./lib/styles/css")); |
| 14 | +} |
14 | 15 |
|
15 | 16 | // library
|
16 |
| -gulp.task('copy_styles', function () { |
17 |
| - return gulp.src('./src/styles/**/*.scss') |
18 |
| - .pipe(gulp.dest('./lib/styles/scss')); |
19 |
| -}); |
| 17 | +function copyStyles() { |
| 18 | + return gulp |
| 19 | + .src("./src/styles/**/*.scss") |
| 20 | + .pipe(gulp.dest("./lib/styles/scss")); |
| 21 | +} |
20 | 22 |
|
21 |
| -gulp.task('build-lib', ['copy_styles', 'build_styles'], function () { |
22 |
| - const tsResult = tsProject.src() |
23 |
| - .pipe(tsProject({ |
24 |
| - declaration: true |
25 |
| - })); |
26 |
| - return merge([ |
27 |
| - tsResult.dts.pipe(gulp.dest('lib/definitions')), |
28 |
| - tsResult.js.pipe(gulp.dest('lib/js')) |
29 |
| - ]); |
30 |
| -}); |
| 23 | +// depends on copyStyles and buildStyles |
| 24 | +function buildLib() { |
| 25 | + const tsResult = tsProject.src().pipe( |
| 26 | + tsProject({ |
| 27 | + declaration: true |
| 28 | + }) |
| 29 | + ); |
| 30 | + return merge([ |
| 31 | + tsResult.dts.pipe(gulp.dest("lib/definitions")), |
| 32 | + tsResult.js.pipe(gulp.dest("lib/js")) |
| 33 | + ]); |
| 34 | +} |
31 | 35 |
|
32 | 36 | // demo
|
33 | 37 | // removes the output configuration from the webpack.config.js file, otherwise it doesn't work.
|
34 | 38 |
|
35 |
| -gulp.task('copy-index', function () { |
36 |
| - return gulp.src('./demo/index.prod.html') |
37 |
| - .pipe(rename('index.html')) |
38 |
| - .pipe(gulp.dest('./docs')); |
39 |
| -}); |
| 39 | +function copyIndex() { |
| 40 | + return gulp |
| 41 | + .src("./demo/index.prod.html") |
| 42 | + .pipe(rename("index.html")) |
| 43 | + .pipe(gulp.dest("./docs")); |
| 44 | +} |
40 | 45 |
|
41 |
| -gulp.task('build-demo', ['copy-index'], function () { |
42 |
| - return gulp.src('demo/client.ts') |
43 |
| - .pipe(webpackStream(require('./webpack.config.demo.prod.js'), require("webpack"))) |
44 |
| - .pipe(gulp.dest('docs/')) |
45 |
| -}); |
| 46 | +// depends on copyIndex |
| 47 | +function buildDemo() { |
| 48 | + return gulp |
| 49 | + .src("demo/client.tsx") |
| 50 | + .pipe( |
| 51 | + webpackStream( |
| 52 | + require("./webpack.config.demo.prod.js"), |
| 53 | + require("webpack") |
| 54 | + ) |
| 55 | + ) |
| 56 | + .pipe(gulp.dest("docs/")); |
| 57 | +} |
46 | 58 |
|
47 |
| -// all |
48 |
| -gulp.task('build', ['build-demo', 'build-lib']); |
| 59 | +exports.build = gulp.series(buildStyles, copyStyles, copyIndex, buildLib, buildDemo); |
0 commit comments