Bundler Transformer Autoprefixer知道物理路径的后处理文件
本文关键字:路径 后处理 文件 Transformer Autoprefixer Bundler | 更新日期: 2023-09-27 17:59:22
我在ASP中有一个项目。NET MVC和我想使用Bundler Transformer Autoprefixer来处理我的css文件。我的用例有点不寻常,我需要从物理路径(如"C:'somewhere'style.css".
)处理css内容我想我可以使用AutoprefixssPostProcessor类来实现这一点,但它允许处理需要文件虚拟路径的资产。是否可以使用AutoprefixssPostProcessor对此类文件进行后处理?
作品:
var tempFileVirtualPath = $"/App_Data/Temp/{Guid.NewGuid()}.css"
System.IO.File.WriteAllText(Server.MapPath(tempFileVirtualPath), initialCssContent);
var autoprefixer = new AutoprefixCssPostProcessor();
var content = autoprefixer.PostProcess(new Asset(tempFileVirtualPath)).Content;
var absolutePath = "C:'somewhere'style.css";
System.IO.File.WriteAllText(absolutePath, content);