-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.ts
46 lines (39 loc) · 1.48 KB
/
gulpfile.ts
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
const gulp = require('gulp')
const ts = require('gulp-typescript');
const webpack = require('webpack')
const webpackConfig = require('./webpack.config.js')
const project = ts.createProject('tsconfig.json')
gulp.task('runWebpack', ()=>{
return new Promise<void>((resolve, reject) => {
webpack(webpackConfig, (err, stats) => {
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
return reject(new Error(stats.compilation.errors.join('\n')))
}
resolve()
})
})
});
gulp.task('compile', () => {
return gulp.src('src/**/*.ts')
.pipe(project())
.pipe(gulp.dest('dist/'))
})
gulp.task('copy', async () => {
gulp.src('README.md').pipe(gulp.dest("dist/"))
gulp.src("src/module.json").pipe(gulp.dest('dist/'))
gulp.src("src/lang/**").pipe(gulp.dest('dist/lang/'))
gulp.src("src/templates/**").pipe(gulp.dest('dist/templates/'))
gulp.src("src/styles/**").pipe(gulp.dest('dist/styles/'))
gulp.src("src/assets/**").pipe(gulp.dest('dist/assets/'))
})
gulp.task('build', gulp.parallel('runWebpack', 'copy'));
// This is supposed to copy the dist folder into the modules directory for testing. Only works if you're relative path is exactly correct
// TODO make this less horribly brittle
const MODULEPATH = "../../AppData/Local/FoundryVTT/Data/modules/foundry-redirect/"
gulp.task('foundry', () => {
return gulp.src('dist/**').pipe(gulp.dest(MODULEPATH))
})
gulp.task("update", gulp.series('build', 'foundry'))