Gur*_*ofu 5 node.js typescript gulp webpack gulp-load-plugins
我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())
// ...
Run Code Online (Sandbox Code Playgroud)
它从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
Run Code Online (Sandbox Code Playgroud)
有人告诉我@types/gulp-load-plugins:
/**
* Extend this interface to use Gulp plugins in your gulpfile.js
*/
interface IGulpPlugins {
}
Run Code Online (Sandbox Code Playgroud)
我试过了:
interface IGulpPlugins {
pug: () => NodeJS.ReadWriteStream;
}
Run Code Online (Sandbox Code Playgroud)
它还定义了:
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;
// ...
}
Run Code Online (Sandbox Code Playgroud)
看起来我可能应该使用gulpLoadPlugins而不是扩展接口......我理解当前的TypeScirpt熟练程度,但是它还不足以理解如何gulp-load-plugins在TypeScript中使用.
| 归档时间: |
|
| 查看次数: |
153 次 |
| 最近记录: |