public Module Transform(Module module) { string fullModulePath = module.FullPath; string moduleId = module.ModuleId; string content = module.TransformedContent ?? _fileSystem.File.ReadAllText(fullModulePath); LibSass.Compiler.SassCompiler compiler = new LibSass.Compiler.SassCompiler(new LibSass.Compiler.Options.SassOptions { Data = content, InputPath = fullModulePath, OutputStyle = LibSass.Compiler.Options.SassOutputStyle.Compressed, Importers = new LibSass.Compiler.Options.CustomImportDelegate[] { new CustomImportDelegate((string currentImport, string parentImport, ISassOptions sassOptions) => { var importPath = _fileSystem.Path.GetFullPath(_fileSystem.Path.Combine(_fileSystem.Path.GetDirectoryName(fullModulePath), currentImport)); return(new SassImport[] { new SassImport { Data = _fileSystem.File.ReadAllText(importPath), Path = importPath } }); }) } }); CssToJsModule cssTransformer = new CssToJsModule(); var css = compiler.Compile().Output; module.OriginalContent = module.OriginalContent ?? content; module.TransformedContent = cssTransformer.Build(css, moduleId); return(module); }
public Module Transform(Module module) { string fullModulePath = module.FullPath; string moduleId = module.ModuleId; string content = module.TransformedContent ?? _fileSystem.File.ReadAllText(fullModulePath); dotless.Core.EngineFactory factory = new dotless.Core.EngineFactory(new dotless.Core.configuration.DotlessConfiguration { Debug = true, ImportAllFilesAsLess = true, InlineCssFiles = true, MinifyOutput = true }); // Temporary solution until Pandora is exposed by Dotless. FileReader.FileSystem = _fileSystem; factory.Configuration.LessSource = typeof(FileReader); var engine = factory.GetEngine(); engine.CurrentDirectory = _fileSystem.Path.GetFullPath(_fileSystem.Path.GetDirectoryName(fullModulePath)); var css = engine.TransformToCss(content, moduleId); CssToJsModule cssTransformer = new CssToJsModule(); module.OriginalContent = module.OriginalContent ?? content; module.TransformedContent = cssTransformer.Build(css, moduleId); return(module); }