-
I know this is a very tired subject, but I have some thoughts and possibly a valid use case. As far I can tell, gulp doesn't ever use package.json {
"build": {
"clean": {
"sass": "./Web/wwwroot/themes/**/*.css",
"typescript": "./Web/wwwroot/themes/**/*.js"
},
"sass": {
"source": "./Web/themes/**/*.sass",
"destination": "./Web/wwwroot/themes"
},
"typescript": {
"source": "./Web/themes/**/main.ts",
"destination": "./Web/wwwroot/themes"
}
}
} Clean.ts import type { TaskFunction } from 'gulp';
import { build } from '../package.json';
import del from 'del';
const config = Object.values(build.clean);
const task: TaskFunction = async function (this: string[] | undefined, /* done */) {
return del(this ?? config);
// done() is still functions, if needed.
};
export default task; Watch.ts import Clean from './Clean';
import Sass from './Sass';
import type { TaskFunction } from 'gulp';
import TypeScript from './TypeScript';
import { build } from '../package.json';
import { series, watch } from 'gulp';
const cleanSass = Clean.bind([build.clean.sass]);
const cleanTypeScript = Clean.bind([build.clean.typescript]);
cleanTypeScript.displayName =
cleanSass.displayName = 'watch;clean';
const task: TaskFunction = () => {
watch(build.sass.source, series(cleanSass, Sass));
watch(build.typescript.source, series(cleanTypeScript, TypeScript));
};
export default task; gulpFile.ts import Clean from './build/Clean';
import Sass from './build/Sass';
import TypeScript from './build/TypeScript';
import Watch from './build/Watch';
import { parallel } from 'gulp';
Sass.displayName = 'build:sass';
TypeScript.displayName = 'build:ts';
const build = parallel(Sass, TypeScript);
Watch.displayName = 'watch';
Clean.displayName = 'clean';
export { build, Sass, TypeScript, Watch, Clean }; I have seen other approaches for passing around arguments, but those suggestions all require:
Additionally, if would be possible to bind anything or type to the So...
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is almost exactly what https://github.com/gulpjs/undertaker-task-metadata does. You can create a registry that uses similar logic but takes a config and binds it to each task based on name. Registries were designed to defer low-level, opinionated behavior, like this, to the consumer. The caveat is that registries don't work perfectly with task exports. We could definitely use someone looking into that. |
Beta Was this translation helpful? Give feedback.
This is almost exactly what https://github.com/gulpjs/undertaker-task-metadata does. You can create a registry that uses similar logic but takes a config and binds it to each task based on name.
Registries were designed to defer low-level, opinionated behavior, like this, to the consumer.
The caveat is that registries don't work perfectly with task exports. We could definitely use someone looking into that.