當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript compilation.warnings.push方法代碼示例

本文整理匯總了TypeScript中webpack.compilation.warnings.push方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript compilation.warnings.push方法的具體用法?TypeScript compilation.warnings.push怎麽用?TypeScript compilation.warnings.push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在webpack.compilation.warnings的用法示例。


在下文中一共展示了compilation.warnings.push方法的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;
            });
開發者ID:cexbrayat,項目名稱:angular-cli,代碼行數:33,代碼來源:cleancss-webpack-plugin.ts

示例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();
      });
    });
開發者ID:fmalcher,項目名稱:angular-cli,代碼行數:23,代碼來源:webpack-plugin.ts


注:本文中的webpack.compilation.warnings.push方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。