<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: BamButz</title>
    <description>The latest articles on DEV Community by BamButz (@bambutz).</description>
    <link>https://dev.to/bambutz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F277801%2Fc8403c2b-1cd8-428f-abbe-bb0ca689a1ec.png</url>
      <title>DEV Community: BamButz</title>
      <link>https://dev.to/bambutz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bambutz"/>
    <language>en</language>
    <item>
      <title>Integrating Tailwind into a Blazor Project</title>
      <dc:creator>BamButz</dc:creator>
      <pubDate>Tue, 23 Jun 2020 09:32:33 +0000</pubDate>
      <link>https://dev.to/bambutz/integrating-tailwind-into-a-blazor-project-549e</link>
      <guid>https://dev.to/bambutz/integrating-tailwind-into-a-blazor-project-549e</guid>
      <description>&lt;p&gt;A few weeks ago I started experimenting with Blazor and quickly found myself in the situation that I wanted to use a CSS framework. So, I started looking for the best way to integrate Tailwind into a Blazor project. I found out that there was no way to integrate Tailwind into the project without creating a project.json and thus having a node_modules directory in the project. Since I was not satisfied with this approach, I looked at how I could design a system that fits better into my project.&lt;/p&gt;

&lt;p&gt;In the end I came up with a solution in which I simply include a NuGet package in the project and assign the build action I gained through it to my stylesheet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;Project&lt;/span&gt; &lt;span class="na"&gt;Sdk=&lt;/span&gt;&lt;span class="s"&gt;"Microsoft.NET.Sdk"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TargetFramework&amp;gt;&lt;/span&gt;netcoreapp3.1&lt;span class="nt"&gt;&amp;lt;/TargetFramework&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;TailwindCSS&lt;/span&gt; &lt;span class="na"&gt;Include=&lt;/span&gt;&lt;span class="s"&gt;"Styles/Tailwind.css"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;PackageReference&lt;/span&gt; &lt;span class="na"&gt;Include=&lt;/span&gt;&lt;span class="s"&gt;"BamButz.MSBuild.TailwindCSS"&lt;/span&gt; &lt;span class="na"&gt;PrivateAssets=&lt;/span&gt;&lt;span class="s"&gt;"All"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/Project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But what is inside the &lt;a href="https://www.nuget.org/packages/BamButz.MSBuild.TailwindCSS/"&gt;NuGet package&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;It simply contains the things I didn't want in my project: the project.json and the node_modules directory, plus an MSBuild target and a JavaScript file.&lt;/p&gt;

&lt;p&gt;It works as follows: The target calls the JavaScript file via node.js and provides information about project &amp;amp; file path, then the JavaScript file proceeds to setup PostCSS and simply loads the source stylesheet into it and writes the output of PostCSS into the target file, wich is stored in the same location as the source file with the extension &lt;em&gt;.min.css&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If you need to use a custom configuration you can simply drop a tailwind.config.js into your project directory as the script is checking for the file before transforming.&lt;/p&gt;

&lt;p&gt;If you want to know more about it, you can take a look at its &lt;a href="https://github.com/BamButz/msbuild-tailwindcss"&gt;Github Repository&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>tailwindcss</category>
      <category>blazor</category>
      <category>msbuild</category>
    </item>
  </channel>
</rss>
