本文整理汇总了TypeScript中loader-utils.interpolateName函数的典型用法代码示例。如果您正苦于以下问题:TypeScript interpolateName函数的具体用法?TypeScript interpolateName怎么用?TypeScript interpolateName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了interpolateName函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: reject
loader.fs.readFile(result, (err: Error, content: Buffer) => {
if (err) {
reject(err);
return;
}
let outputPath = interpolateName(
{ resourcePath: result } as webpack.loader.LoaderContext,
filename,
{ content },
);
if (resourcesOutputPath) {
outputPath = path.posix.join(resourcesOutputPath, outputPath);
}
loader.addDependency(result);
loader.emitFile(outputPath, content, undefined);
let outputUrl = outputPath.replace(/\\/g, '/');
if (hash || search) {
outputUrl = url.format({ pathname: outputUrl, hash, search });
}
if (deployUrl && loader.loaders[loader.loaderIndex].options.ident !== 'extracted') {
outputUrl = url.resolve(deployUrl, outputUrl);
}
resourceCache.set(cacheKey, outputUrl);
resolve(outputUrl);
});
示例2: reject
loader.fs.readFile(result, (err: Error, content: Buffer) => {
if (err) {
reject(err);
return;
}
const outputPath = interpolateName(
{ resourcePath: result } as webpack.loader.LoaderContext,
filename,
{ content },
);
loader.addDependency(result);
loader.emitFile(outputPath, content, undefined);
let outputUrl = outputPath.replace(/\\/g, '/');
if (hash || search) {
outputUrl = url.format({ pathname: outputUrl, hash, search });
}
if (deployUrl) {
outputUrl = url.resolve(deployUrl, outputUrl);
}
resourceCache.set(inputUrl, outputUrl);
resolve(outputUrl);
});
示例3: bookLoader
module.exports = function bookLoader(content: string): string {
this.cacheable(true);
const query = loaderUtils.parseQuery(this.query);
const {toc} = query;
const {attributes, body} = fm<{[key: string]: any}>(content);
if (query.markdown === false || attributes.markdown === false) {
content = jsTemplate(body);
} else {
const {bookLoaderOptions = {}} = this;
const md = markdownIt({
html: true,
...bookLoaderOptions.markdownOptions,
}).use(markdownJsTemplate);
if (bookLoaderOptions.markdownPlugins) {
bookLoaderOptions.markdownPlugins.forEach(md.use.bind(md));
}
content = md.render(body);
}
const context = query.context || this.options.context;
const url = attributes.hasOwnProperty('url')
? attributes.url
: loaderUtils.interpolateName(this, query.name || '[path][name].html', {
context,
content: content,
regExp: query.regExp,
});
const template = attributes.hasOwnProperty('template')
? attributes.template
: query.template;
const emit = !![attributes.emit, query.emit, url].find(
(o) => typeof o !== 'undefined',
);
return pageModuleTemplate({
url,
template,
toc,
attributes,
emit,
filename: path.relative(context, this.resourcePath),
renderFunctionBody: content,
});
};