Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to include bootstrap or other css library files in .bundle.scp.css #35898

Closed
sam-wheat opened this issue Aug 28, 2021 · 4 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-css-isolation This issue is related to CSS Isolation feature ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@sam-wheat
Copy link

Reference:

dotnet/AspNetCore.Docs#16837

dotnet/AspNetCore.Docs#20931

Documentation

1.) How to include bootstrap or other css library files in .bundle.scp.css

This documentation says:

To include companion assets as part of an RCL, create a wwwroot folder in the class library and include any required files in that folder.
When packing an RCL, all companion assets in the wwwroot folder are automatically included in the package.
Use the dotnet pack command rather than the NuGet.exe version nuget pack.

In my case the css in wwwroot is not not included in the bundle file. To reference wwwroot css in my project I have to the second link shown below in the consuming project:

<link href="_content/MyComponent/MyComponent.bundle.scp.css" rel="stylesheet" />
<link href="_content/MyComponent/css/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

In the file produced in obj/debug/net5.0/scopedcss/projectbundle/MyComponent/MyComponent.bundle.scp.css there is no reference to the wwwroot files. Here is the exact content:

@import '';

/* _content/MyComponent/MyComponent.razor.rz.scp.css */
.my-container[b-sd16mhok0g] {
  display: flex;
  flex: 1 1 0; }

I tried using dotnet pack as indicated in the documentation and referencing the nuget in the host project. It makes no difference. Currently I am referencing the RCL as a project so I can develop using dotnet run watch. Is this supported?

2.) How to isolate wwwroot level css libraries in RCL projects

This may be answered by #1 above however I want to ask specifically. My host project uses an older version of bootstrap and those styles are affecting my control.

@javiercn javiercn added area-blazor Includes: Blazor, Razor Components area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-css-isolation This issue is related to CSS Isolation feature labels Aug 30, 2021
@javiercn
Copy link
Member

@sam-wheat thanks for contacting us.

The bundles that we generate are meant to contain only scoped CSS associated, not random CSS files.

We don't plan to support including other contents since we don't deal with things like ordering and de-duplication. We still recommend you place a link tag on your document head to bring in the regular CSS you need.

@javiercn javiercn added ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question labels Aug 30, 2021
@ghost ghost added the Status: Resolved label Aug 30, 2021
@sam-wheat
Copy link
Author

Hi @javiercn,

I think what you said directly contradicts this line in the documentation cited above:

When packing an RCL, all companion assets in the wwwroot folder are automatically included in the package.

Are we talking about the same thing? If what you say is true the docs should definitely be changed as the current guidance is misleading.

Thanks for your response.

@javiercn
Copy link
Member

Assets are included in the package, however you still need to reference them in your app.

It's not clear that the docs are misleading in that sense. It sounds pretty clear to me that it only talks about the content being included in the package, that's different from including a file within another file in the context of a different feature.

@ghost
Copy link

ghost commented Aug 31, 2021

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Aug 31, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Sep 30, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-css-isolation This issue is related to CSS Isolation feature ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants