-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
50 lines (43 loc) · 1.33 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
import path from 'node:path';
import gulp from 'gulp';
import replace from 'gulp-replace';
import { createConfig } from '@middlebury/gulp-config';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const { cwd } = process;
const args = yargs(hideBin(process.argv)).argv;
const DIST_DIR = 'dist';
const SOURCE_DIR = 'src';
const dist = (parts = '') => path.resolve(cwd(), DIST_DIR, parts);
const src = (parts) => path.resolve(cwd(), SOURCE_DIR, parts);
const copyDeps = () => {
// NOTE: Chart.bundle.min.js includes Momentjs but so far we are not using time axis
// http://www.chartjs.org/docs/latest/getting-started/installation.html#bundled-build
return gulp
.src('./node_modules/chart.js/dist/Chart.min.js')
.pipe(gulp.dest('./dist/js'));
};
const copyMeta = () => {
return gulp
.src([
'./composer.json'
])
.pipe(gulp.dest('./dist/'));
};
export const replaceImagePaths = () => {
const imagesDir = args.imagesDir || '/img/';
return gulp
.src('./dist/css/*.css')
.pipe(replace('/img/', imagesDir))
.pipe(gulp.dest('./dist/css'));
};
const options = {
scripts: {
src: src('js/index.ts'),
watch: src('js/**/*'),
dest: dist('js/bundle.js')
},
beforeBuild: [copyDeps, copyMeta],
typescriptBuild: true
};
export const { dev, build } = createConfig(options);