forked from mathigon/textbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (47 loc) · 1.89 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
// =============================================================================
// Mathigon Textbooks Gulpfile
// (c) Mathigon
// =============================================================================
const gulp = require('gulp');
const rollup = require('gulp-better-rollup');
const less = require('gulp-less');
const postcss = require('gulp-postcss');
const rename = require('gulp-rename');
const resolve = require('rollup-plugin-node-resolve');
const typescript = require('rollup-plugin-typescript');
const autoprefixer = require('autoprefixer');
const gulpTextbooks = require('@mathigon/parser').gulp;
const tsconfig = require('./tsconfig.json');
const rtl = require('postcss-rtl');
const LANGUAGES = ['en', 'ar', 'cn', 'de', 'es', 'fr', 'hi', 'it', 'ja', 'pt',
'ru', 'sv', 'tr', 'vi', 'fa', 'mr'];
const CACHE = __dirname + '/content/.cache.json';
function markdown() {
return gulp.src(['content/*/', '!content/shared/'])
.pipe(gulpTextbooks(LANGUAGES, CACHE))
.pipe(gulp.dest('server/assets/resources'));
}
function scripts() {
return gulp.src(['content/*/*.ts', '!content/shared/**'])
.pipe(rollup({
plugins: [typescript(tsconfig.compilerOptions), resolve()],
onwarn(e) {
if (e.code !== 'CIRCULAR_DEPENDENCY') console.warn(e.message);
}
}, {format: 'iife', name: 'StepFunctions'}))
.pipe(rename({extname: '.js'}))
.pipe(gulp.dest('server/assets/resources'));
}
function stylesheets() {
return gulp.src(['content/*/*.less', '!content/shared/**'])
.pipe(less())
.pipe(postcss([rtl(), autoprefixer()]))
.pipe(rename({extname: '.css'}))
.pipe(gulp.dest('server/assets/resources'));
}
exports.watch = () => {
gulp.watch('content/**/*.{md,yaml}', markdown);
gulp.watch('content/**/*.ts', scripts);
gulp.watch('content/**/*.less', stylesheets);
};
exports.default = gulp.parallel(markdown, scripts, stylesheets);