gulp-load-plugins
我在 TypeScript 中找不到任何示例。不幸的是,我的 TypeScript 太差了,无法理解,从@type/gulp-load-plugins
评论中应该做什么。
我试过了:
import * as _gulpPlugins from 'gulp-load-plugins';
const gulpPlugins: IGulpPlugins = _gulpPlugins();
return gulp.src(sourceFilesGlobSelections)
.pipe(gulpPlugins.pug())
// ...
它从 Webpack 发出 4 个警告(我不明白这样的数字在哪里75:13-25
;.pipe(gulpPlugins.pug())
在 50 行):
WARNING in ../node_modules/gulp-load-plugins/index.js 75:13-25
Critical dependency: the request of a dependency is an expression
@ ./TaskManagers/MarkupPreprocessingHelper.ts
WARNING in ../node_modules/gulp-load-plugins/index.js 81:48-63
Critical dependency: the request of a dependency is an expression
@ ./TaskManagers/MarkupPreprocessingHelper.ts
WARNING in ../node_modules/gulp-load-plugins/index.js 117:40-55
Critical dependency: the request of a dependency is an expression
@ ./TaskManagers/MarkupPreprocessingHelper.ts
WARNING in ../node_modules/gulp-load-plugins/index.js 122:51-66
Critical dependency: the request of a dependency is an expression
@ ./TaskManagers/MarkupPreprocessingHelper.ts
它被告知@types/gulp-load-plugins
:
/**
* Extend this interface to use Gulp plugins in your gulpfile.js
*/
interface IGulpPlugins {
}
我试过了:
interface IGulpPlugins {
pug: () => NodeJS.ReadWriteStream;
}
它还定义了:
declare module 'gulp-load-plugins' {
interface IOptions {
// ...
}
interface IPluginNameMappings {
[npmPackageName: string]: string
}
/** Loads in any gulp plugins and attaches them to an object, freeing you up from having to manually require each gulp plugin. */
function gulpLoadPlugins<T extends IGulpPlugins>(options?: IOptions): T;
// ...
}
看起来也许我应该使用gulpLoadPlugins
而不是接口扩展......这就是我目前的 TypeScirpt 熟练程度所了解的全部内容,但还不足以了解如何gulp-load-plugins
在 TypeScript 中使用。