Coder Social home page Coder Social logo

uabarahona / blazor-tailwindcss-template Goto Github PK

View Code? Open in Web Editor NEW
42.0 42.0 9.0 401 KB

This template demostrates the integration of tailwindcss with blazor and covers important features like hot-reload and css isolation

License: MIT License

HTML 47.25% CSS 45.24% C# 3.67% JavaScript 3.85%
asp-net-core aspnetcore blazor blazor-webassembly csharp dotnet tailwindcss

blazor-tailwindcss-template's Introduction

blazor-tailwindcss-template's People

Contributors

arkada38 avatar uabarahona avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

blazor-tailwindcss-template's Issues

Thank you!

Truely I was looking for this since weeks and you made it!
Thank you 1000 times!

Just in case here is my project config I have all NPM shit in a folder NpmJS, and I differ between publish and build.
Maybe this helps someone else who has the same problem

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled>
    <StaticWebAssetBasePath>_content</StaticWebAssetBasePath>
    <NodeFiles>NpmJS\</NodeFiles>
  </PropertyGroup

  <ItemGroup>
    <Content Remove="$(NodeFiles)**" />
    <None Remove="$(NodeFiles)**" />
    <None Include="$(NodeFiles)**" Exclude="$(NodeFiles)node_modules\**" />
  </ItemGroup>

  <ItemGroup>
    <styles Include="$(NodeFiles)src\app.css" />
    <Watch Include="@(styles)" />
  </ItemGroup>

  <Target Name="DeleteExistingBuild" BeforeTargets="ComputeFilesToPublish">
    <RemoveDir Directories="$(PublishDir)" />
    <Message Importance="high" Text="Cleared publish folder" />
  </Target>

  <Target Name="NpmInstall" Inputs="$(MSBuildProjectDirectory)\NpmJS\package-lock.json" Outputs="$(BaseIntermediateOutputPath)\NpmJS\package-lock.json">
    <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
    <Exec Command="npm install" WorkingDirectory="$(MSBuildProjectDirectory)\NpmJS" />
    <Copy SourceFiles="$(MSBuildProjectDirectory)\NpmJS\package-lock.json" DestinationFolder="$(BaseIntermediateOutputPath)\NpmJS" SkipUnchangedFiles="true" />
  </Target>

  <Target Name="PostScopedCssCompile" AfterTargets="_GenerateScopedCssFiles" DependsOnTargets="NpmInstall">
    <Message Importance="high" Text="Building scoped css..." />
    <Exec Command="npx postcss @(_ScopedCssOutputs, ' ') --replace --config $(MSBuildProjectDirectory)\NpmJS" WorkingDirectory="$(MSBuildProjectDirectory)\NpmJS" EnvironmentVariables="TAILWIND_MODE=build" />
  </Target>

  <Target Name="PostStylesCssCompile" Inputs="@(styles)" Outputs="@(styles->'$(MSBuildProjectDirectory)\wwwroot\css\%(FileName)%(Extension)')" BeforeTargets="CoreBuild">
    <Message Importance="high" Text="(CoreBuild) Building styles css" />
    <Exec Command="npx postcss @(styles->'src\%(FileName)%(Extension)', ' ') --dir $(MSBuildProjectDirectory)\wwwroot\css --config $(MSBuildProjectDirectory)\NpmJS" WorkingDirectory="$(MSBuildProjectDirectory)\NpmJS" EnvironmentVariables="TAILWIND_MODE=build" />
  </Target>

  <Target Name="PostStylesCssPublish" Inputs="@(styles)" Outputs="@(styles->'$(PublishDir)\wwwroot\css\%(FileName)%(Extension)')" AfterTargets="ComputeFilesToPublish">
    <Message Importance="high" Text="(ComputeFilesToPublish) Building styles css" />
    <Exec Command="npx postcss @(styles->'src\%(FileName)%(Extension)', ' ') --dir $(PublishDir)\wwwroot\css --config $(MSBuildProjectDirectory)\NpmJS" WorkingDirectory="$(MSBuildProjectDirectory)\NpmJS" EnvironmentVariables="TAILWIND_MODE=build" />
  </Target>
</Project>

`styles.css` changes triggers true hot reload instead of full rebuild

Description

Right now, changes on styles.css will trigger a full reload when executing the project with dotnet watch, ideally it should execute a true hot reload.

Taks

  • changes on styles.css executes true hot reload
  • changes on any .razor files triggers a hot reload on styles.css
    • JIT-compiler emits only the necessary css for the directives used on .razor files, any time a new directive is added we should trigger a hot reload on styles.css

Awesome!

Thank you very much for your efforts and sharing this tools.
I hope you had a time to finish this ASAP.
Wish you al the best.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.