本文整理汇总了TypeScript中webpack.compilation.warnings类的典型用法代码示例。如果您正苦于以下问题:TypeScript compilation.warnings类的具体用法?TypeScript compilation.warnings怎么用?TypeScript compilation.warnings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了compilation.warnings类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Error
.then((output: any) => {
let hasWarnings = false;
if (output.warnings && output.warnings.length > 0) {
compilation.warnings.push(...output.warnings);
hasWarnings = true;
}
if (output.errors && output.errors.length > 0) {
output.errors
.forEach((error: string) => compilation.errors.push(new Error(error)));
return;
}
// generally means invalid syntax so bail
if (hasWarnings && output.stats.minifiedSize === 0) {
return;
}
let newSource;
if (output.sourceMap) {
newSource = new SourceMapSource(
output.styles,
file,
output.sourceMap.toString(),
content,
map,
);
} else {
newSource = new RawSource(output.styles);
}
compilation.assets[file] = newSource;
});
示例2: purifyReplacements
compiler.plugin('compilation', (compilation: compilation.Compilation) => {
// Webpack 4 provides the same functionality as this plugin and TS transformer
compilation.warnings.push('PurifyPlugin is deprecated and will be removed in 0.7.0.');
compilation.plugin('optimize-chunk-assets', (chunks: Chunk[], callback: () => void) => {
chunks.forEach((chunk: Chunk) => {
chunk.files
.filter((fileName: string) => fileName.endsWith('.js'))
.forEach((fileName: string) => {
const inserts = purifyReplacements(compilation.assets[fileName].source());
if (inserts.length > 0) {
const replaceSource = new ReplaceSource(compilation.assets[fileName], fileName);
inserts.forEach((insert) => {
replaceSource.insert(insert.pos, insert.content);
});
compilation.assets[fileName] = replaceSource;
}
});
});
callback();
});
});