LibSassHost
LibSassHost copied to clipboard
Error: File to import not found or unreadable
Hello
I recently updated LibSassHost in my project to 1.3.1 and with the following .scss file am getting an error. The bootstrap.scss file is in the same folder as the file with this code. Any help would be appreciated.
` $enable-gradients: true; $enable-shadows: true; $enable-print-styles: false;
$blue: #337ab7; $gray-100: #f5f5f5;
$border-radius: 4px;
$table-hover-bg: $blue;
$navbar-nav-link-padding-x: 15px;
$nav-link-padding-y: .833rem; $nav-link-padding-x: 1.25rem;
@import "bootstrap"; `
the error is here:
BundleTransformer.Core.Translators.AssetTranslationException Occurred.
Message: During translation of SCSS code, readed from the file '/Rep/Content/bootstrap/custom.scss', to CSS code syntax error has occurred. See more details:
Error: File to import not found or unreadable: bootstrap. on line 17:1 of Content/bootstrap/custom.scss
@import "bootstrap"; ^
Error code: 1 Description: File to import not found or unreadable: bootstrap. File: /Rep/Content/bootstrap/custom.scss Line number: 17 Column number: 1 Source fragment:
Line 17: @import "bootstrap"; ---------^ Data: TargetSite: Void InnerTranslate(BundleTransformer.Core.Assets.IAsset, LibSassHost.CompilationOptions, Boolean) HelpLink: NULL Source: BundleTransformer.SassAndScss HResult: -2146233088
Stack Trace:
at BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.InnerTranslate(IAsset asset, CompilationOptions sassOptions, Boolean enableNativeMinification)
at BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.Translate(IList1 assets) at BundleTransformer.Core.Transformers.TransformerBase.Translate(IList1 assets, Boolean isDebugMode)
at BundleTransformer.Core.Transformers.TransformerBase.Transform(IList1 assets, BundleContext bundleContext, BundleResponse bundleResponse, VirtualPathProvider virtualPathProvider, Boolean isDebugMode) at BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext bundleContext, BundleResponse bundleResponse, Boolean isDebugMode) at BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext bundleContext, BundleResponse bundleResponse) at System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable1 bundleFiles)
at System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context)
at BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleResponse(Bundle bundle, BundleContext context)
at BundleTransformer.Core.Resolvers.CustomBundleResolver.GetBundleContents(String bundleVirtualPath)
at System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets)
at System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths)
at System.Web.Optimization.Styles.RenderFormat(String tagFormat, String[] paths)
at System.Web.Optimization.Styles.Render(String[] paths)
at Gwi.cSupport.Web.UI.PageBase.OnInit(EventArgs e) in C:\iSupport Source\iSupport\Main Trunk\Main Application\c.Support\Web\Framework\UI\PageBase.cs:line 72
at Gwi.cSupport.Web.UI.LicensedPageBase.OnInit(EventArgs e) in C:\iSupport Source\iSupport\Main Trunk\Main Application\c.Support\Web\Framework\UI\LicensedPageBase.cs:line 41
at System.Web.UI.Control.d__225.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Util.WithinCancellableCallbackTaskAwaitable.WithinCancellableCallbackTaskAwaiter.GetResult()
at System.Web.UI.Page.d__523.MoveNext()
Hello, Caleb!
In my case, this problem does not occur. Try making a demo project that reproduces this error and send me a link to it.
I'm having the same issue on a WebForms WebSite project.
As a workaround you can use an absolute path:
@import "~/Rep/Content/bootstrap/bootstrap";
Try upgrading to version 1.3.2.
The issue is still there after upgrading LibSassHost (and native dependency) to 1.3.2 and BundleTransformer.SassAndScss to 1.12.22, only the absolute path starting with ~ works.
Same as above. My "site.scss" is the following:
@import "overrides";
@import "offcanvas";
@import "common";
@import "bootstrap-icons/style";
I noticed that, after the application starts, if i edit the request from "site.scss" to "site.css", reload the page, and change the reference back to "site.scss" it works as expected.
I'm using last version of everything.
I am also having the same issue. My code looks like this:
SassCompiler.Compile(strUserThemeSCSS, "~/CSS/input.scss");
I'm having the same issue on a WebForms WebSite project.
As a workaround you can use an absolute path:
@import "~/Rep/Content/bootstrap/bootstrap";
I even tried doing a .Replace("../", "~/") on strUserThemeSCSS for the @import paths in my SCSS as suggested by @TristanPct but this did not change anything.
I also have this import in another .scss file and it compiles fine when saved.
Error: File to import not found or unreadable: ~/Assets/Bootstrap-4.5.3/CSS/_functions.scss. on line 59:1 of ~/CSS/input.scss >> @import "~/Assets/Bootstrap-4.5.3/CSS/_functions.scss"; ^
@HGCollier If you are trying to run the following code:
SassCompiler.Compile(strUserThemeSCSS, "~/CSS/input.scss");
Then first you need to write your own file manager. A good example of implementing a custom file manager, which provides access to the virtual file system, is the VirtualFileManager class from the BundleTransformer.SassAndScss package.
And then set it:
SassCompiler.FileManager = CustomFileManager();
Keep practicing with sass bro...I am practicing maths
@HGCollier If you are trying to run the following code:
SassCompiler.Compile(strUserThemeSCSS, "~/CSS/input.scss");Then first you need to write your own file manager. A good example of implementing a custom file manager, which provides access to the virtual file system, is the
VirtualFileManagerclass from the BundleTransformer.SassAndScss package.And then set it:
SassCompiler.FileManager = CustomFileManager();
I don't see this in the provided simple example, what I am trying to achieve is pretty much the same so I'm not sure why there would be any need for an external CustomFileManager? I might be misinterpreting the docs though.
Try to import something else and see if the error occurs again. I met you on omegle using C++ as interest.
… I'm not sure why there would be any need for an external CustomFileManager?
Original library does not support paths starting with a ~/. This feature was added to the LibSass Host after numerous requests from users.
Try to import something else and see if the error occurs again.
I changed the @import to @import "example.scss", example.scss is in the same directory as the scss input/output file I am trying to compile.
… I'm not sure why there would be any need for an external CustomFileManager?
Original library does not support paths starting with a
~/. This feature was added to the LibSass Host after numerous requests from users.
So if I were to not use ~/ I wouldn't need a CustomFileManager right? Also even when not using ~/ I still have the same error. However when I manually save the file, everything is imported fine...
This is the structure of my project:
/
/Assets
/Bootstrap-4.5.3
/CSS
_functions.scss
...
/CSS
Master.scss
My @import looks like this: @import '../Assets/Bootstrap-4.5.3/CSS/functions'.
@HGCollier It depends on the type of your application. For example, a web application will most likely need an external CustomFileManager.
@HGCollier It depends on the type of your application. For example, a web application will most likely need an external CustomFileManager.
Ok, so my project is a web application. Following this advice I have installed BundleTransformer.Core and BundleTransformer.SassAndScss via Nuget. At the top of my .cs I have put the using BundleTransformer.SassAndScss.Internal; but because the VirtualFileManager is internal I cannot access it. Is there any way around this, or am I just using the library wrong?
At the top of my .cs I have put the using
BundleTransformer.SassAndScss.Internal;but because theVirtualFileManageris internal I cannot access it.
VirtualFileManager class is just an example, so that you can write your own version.
Your project is based on .NET Framework or .NET Core?
Your project is based on .NET Framework or .NET Core?
.NET Framework
Then try to use the Microsoft ASP.NET Web Optimization Framework and Bundle Transformer libraries. Start reading the following sections of documentation: “Before you read” and “Examples of usage”.
I also recommend reading the “LibSass is Deprecated” article.
Then try to use the Microsoft ASP.NET Web Optimization Framework and Bundle Transformer libraries.
Will these libraries allow me to compile SCSS from a C# script? I essentially create a new SCSS file, let's say from the press of a button and then I would like to trigger a compilation of that file without having to manually save it in my IDE.
Not directly, because these libraries are responsible for asset management and bundling.
This is why I am trying to use this library, as I need to compile my SCSS from C# on the fly.
@HGCollier It is possible that an alternative solution is more suitable for you - SharpScss.
Do you need bootstrap only? You can use any alternative and lets see if you able to accomplish the final goal. Google "Bootstrap alternatives".