本文整理匯總了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();
});
});