当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript html-minifier.minify函数代码示例

本文整理汇总了TypeScript中html-minifier.minify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript minify函数的具体用法?TypeScript minify怎么用?TypeScript minify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了minify函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: minify

    return es.map(function(file: any, callback: (err: any, htmlMinifierfile: any) => void) {
        var template = '$templateCache.put("<%= url %>","<%= contents %>");';
        var url;

        file.path = path.normalize(file.path);

        if(typeof options.path === 'function') {
            url = path.join(options.path(file.path, file.base));
        } else {
            url = path.join(file.path);
            url = url.replace(file.base, '');
        };

        if (process.platform === 'win32') {
            url = url.replace(/\\/g, '/');
        }

        let contents = file.contents.toString();

        if(options.htmlMinifier) {
            contents = minify(contents, options.htmlMinifier);
        }

        contents = require('js-string-escape')(contents);

        file.contents = Buffer.from(lodashTemplate(template)({
            url: url,
            contents: contents,
            file: file
        }), 'utf8');

        callback(null, file);
    });
开发者ID:VictorQueiroz,项目名称:gulp-ng-templates,代码行数:33,代码来源:index.ts

示例2: minifyHtml

global['collapseSpacesReplacement'] = (html: string) => {
	return minifyHtml(html, {
		collapseWhitespace: true,
		collapseInlineTagWhitespace: true,
		keepClosingSlash: true
	}).replace(/\t/g, '');
};
开发者ID:ha-dai,项目名称:Misskey,代码行数:7,代码来源:webpack.config.ts

示例3: minifyHtml

export function minifyHtml(html: string) {
  return htmlMinify(html, {
    removeComments: true,
    removeScriptTypeAttributes: true,
    removeStyleLinkTypeAttributes: true,
    collapseWhitespace: true,
    minifyJS: true,
    minifyCSS: true
  });
}
开发者ID:cpylua,项目名称:cheli.im,代码行数:10,代码来源:minify-html.ts

示例4: minify

export function minify(html: string): string {
  return htmlMinifier.minify(html, {
    caseSensitive: true,
    collapseWhitespace: true,
    conservativeCollapse: true,
    minifyCSS: true,
    minifyJS: true,
    processScripts: ['text/template'],
    removeComments: true,
  });
};
开发者ID:Urigo,项目名称:meteor-static-html-compiler,代码行数:11,代码来源:utils.ts

示例5: minifyHtml

export function minifyHtml(html: string) {
  const options: htmlMinifier.Options = {
    caseSensitive: true,
    collapseWhitespace: true,
    minifyCSS: true,
    minifyJS: true,
    removeComments: true
  };

  return htmlMinifier.minify(html, options);
}
开发者ID:kevinphelps,项目名称:kevinphelps.me,代码行数:11,代码来源:prerender.ts

示例6: minify

export function minify(html: string): string {
  // Just parse the html to make sure it is correct before minifying
  HTMLTools.parseFragment(html);

  return htmlMinifier.minify(html, {
    collapseWhitespace: true,
    conservativeCollapse: true,
    minifyCSS: true,
    minifyJS: true,
    processScripts: ['text/template'],
  });
};
开发者ID:jellyjs,项目名称:meteor-static-html-compiler,代码行数:12,代码来源:utils.ts

示例7: minify

export function minify(html: string): string {
  return htmlMinifier.minify(html, {
    collapseWhitespace: true,
    conservativeCollapse: true,
    minifyCSS: true,
    minifyJS: true,
    processScripts: ['text/template'],
    removeAttributeQuotes: false,
    caseSensitive: true,
    customAttrSurround: [ [/#/, /(?:)/], [/\*/, /(?:)/], [/\[?\(?/, /(?:)/] ],
    customAttrAssign: [ /\)?\]?=/ ],
  });
};
开发者ID:kamilkisiela,项目名称:meteor-static-html-compiler,代码行数:13,代码来源:utils.ts

示例8: catch

 options.renderer.render(options.indexFilename, config, (err, html) => {
   if (err) {
     console.log(err);
     return;
   }
   try {
     fs.accessSync(options.targetPath);
   } catch (e) {
     fs.mkdirSync(options.targetPath);
   }
   console.log(html);
   const minifiedHtml = minify(html, {
     minifyCSS: true,
     minifyJS: true,
     removeComments: true,
     collapseWhitespace: true
   });
   // console.log(minifiedHtml);
   fs.writeFileSync(options.targetPath + '/index.html', minifiedHtml);
 });
开发者ID:narr,项目名称:narr,代码行数:20,代码来源:generator.ts

示例9: minify_html

export default function minify_html(html: string) {
	return minify(html, {
		collapseBooleanAttributes: true,
		collapseWhitespace: true,
		conservativeCollapse: true,
		decodeEntities: true,
		html5: true,
		ignoreCustomComments: [/^#/],
		minifyCSS: true,
		minifyJS: false,
		removeAttributeQuotes: true,
		removeComments: true,
		removeOptionalTags: true,
		removeRedundantAttributes: true,
		removeScriptTypeAttributes: true,
		removeStyleLinkTypeAttributes: true,
		sortAttributes: true,
		sortClassName: true
	});
}
开发者ID:varholak-peter,项目名称:sapper,代码行数:20,代码来源:minify_html.ts

示例10: function

    start: function (resource, options, gOptions, wp) {
        var opt = options;
        var isDebug = gOptions.debug;

        if (!isDebug) {
            var html = resource.value('string');
            resource.set('string', htmlmin(html, opt));
        }
    }
开发者ID:rudarobson,项目名称:webler,代码行数:9,代码来源:htmlmin.ts


注:本文中的html-minifier.minify函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。