Beispiel #1
0
        protected override string BeforeMinify(string outputFile, List <string> filePaths)
        {
            var outputCss = new StringBuilder();

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

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

                ICssAssetsFileHasher fileHasher = null;

                if (ShouldAppendHashForAssets)
                {
                    var fileResolver = new FileResolver();
                    fileHasher = new CssAssetsFileHasher(HashKeyName, fileResolver, hasher);
                }

                css = CSSPathRewriter.RewriteCssPaths(outputFile, file, css, fileHasher);
                outputCss.Append(css + "\n");
            }

            return(outputCss.ToString());
        }
Beispiel #2
0
        string ProcessCssFile(string file, string outputFile, string fileForCssRewriter, bool asImport = false)
        {
            var preprocessors = FindPreprocessors(file);

            var css = preprocessors.NullSafeAny()
                ? PreprocessFile(file, preprocessors)
                : ReadFile(file);

            if (ShouldImport)
            {
                css = ProcessImport(file, outputFile, css);
            }

            ICSSAssetsFileHasher fileHasher = null;

            if (ShouldAppendHashForAssets)
            {
                var fileResolver = new FileSystemResolver();
                fileHasher = new CSSAssetsFileHasher(bundleState.HashKeyName, fileResolver, hasher, pathTranslator);
            }

            return(CSSPathRewriter.RewriteCssPaths(outputFile, fileForCssRewriter, css, fileHasher, asImport));
        }