Exemplo n.º 1
0
        private StringBuilder CompressCss(string outputFilePath, List <string> files, ICssCompressor compressor)
        {
            var outputCss = new StringBuilder();

            foreach (string file in files)
            {
                string css;
                if (file.ToLower().EndsWith(".less") || file.ToLower().EndsWith(".less.css"))
                {
                    css = ProcessLess(file);
                }
                else
                {
                    css = ReadFile(file);
                }

                if (processImports)
                {
                    css = ProcessImport(css);
                }
                css = CssPathRewriter.RewriteCssPaths(outputFilePath, file, css);
                outputCss.Append(compressor.CompressContent(css));
            }
            return(outputCss);
        }
Exemplo n.º 2
0
        private string CompressCss(string outputFilePath, List <string> files, ICssCompressor compressor, bool appendHashToAssets)
        {
            var outputCss = new StringBuilder();

            foreach (string file in files)
            {
                string css;
                if (file.ToLower().EndsWith(".less") || file.ToLower().EndsWith(".less.css"))
                {
                    css = ProcessLess(file);
                }
                else
                {
                    css = ReadFile(file);
                }

                if (processImports)
                {
                    css = ProcessImport(css);
                }

                ICssAssetsFileHasher fileHasher = null;

                if (appendHashToAssets)
                {
                    var fileResolver = new FileResolver();
                    fileHasher = new CssAssetsFileHasher(hashQueryStringKeyName, fileResolver, hasher);
                }

                css = CssPathRewriter.RewriteCssPaths(outputFilePath, file, css, fileHasher);
                outputCss.Append(css + "\n");
            }
            return(compressor.CompressContent(outputCss.ToString()));
        }