Ejemplo n.º 1
0
        public override async Task TransformAsync(IBundleItemTransformContext context)
        {
            string        filePath;
            IFileProvider fileProvider;

            if (context is IFileBundleItemTransformContext fileItemContext)
            {
                filePath     = fileItemContext.FilePath;
                fileProvider = fileItemContext.FileProvider;
            }
            else
            {
                filePath     = null;
                fileProvider = null;
            }

            PathString pathPrefix = context.BuildContext.BundlingContext.StaticFilesPathPrefix;
            PathString outputPath = context.BuildContext.BundlingContext.BundlesPathPrefix.Add(context.BuildContext.Bundle.Path);

            LessCompilationResult result = await _compiler.CompileAsync(context.Content, pathPrefix, filePath, fileProvider, outputPath, context.BuildContext.CancellationToken);

            context.Content = result.Content ?? string.Empty;
            if (result.Imports != null && result.Imports.Count > 0)
            {
                context.BuildContext.ChangeSources?.UnionWith(result.Imports.Select(import => new AbstractionFile(fileProvider, import)));
            }
        }
Ejemplo n.º 2
0
        public override async Task TransformAsync(IBundleItemTransformContext context)
        {
            string        filePath;
            IFileProvider fileProvider;

            if (context is IFileBundleItemTransformContext fileItemContext)
            {
                filePath     = fileItemContext.FilePath;
                fileProvider = fileItemContext.FileProvider;
            }
            else
            {
                filePath     = null;
                fileProvider = null;
            }

            var pathPrefix = context.BuildContext.HttpContext.Request.PathBase + context.BuildContext.BundlingContext.StaticFilesPathPrefix;

            context.Content = await _compiler.CompileAsync(context.Content, pathPrefix, filePath, fileProvider);
        }