<?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: SK</title>
    <description>The latest articles on DEV Community by SK (@skfrozencloud).</description>
    <link>https://dev.to/skfrozencloud</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%2F510843%2F0b0fa1fe-d64a-4ced-bd17-84a775a1a97d.png</url>
      <title>DEV Community: SK</title>
      <link>https://dev.to/skfrozencloud</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/skfrozencloud"/>
    <language>en</language>
    <item>
      <title>Svelte with Tailwind CSS</title>
      <dc:creator>SK</dc:creator>
      <pubDate>Mon, 09 Nov 2020 13:03:37 +0000</pubDate>
      <link>https://dev.to/skfrozencloud/svelte-with-tailwind-css-3am7</link>
      <guid>https://dev.to/skfrozencloud/svelte-with-tailwind-css-3am7</guid>
      <description>&lt;p&gt;Yet another Svelte and Tailwind CSS installation post.&lt;/p&gt;

&lt;p&gt;I have been looking through several guides on how to install Tailwind CSS in Svelte and this is my final way of doing it. I am in no way an expert in this and there are definitely many correct ways of doing it.&lt;/p&gt;

&lt;p&gt;Heavily influenced by these posts:&lt;br&gt;
&lt;a href="https://dev.to/swyx/how-to-set-up-svelte-with-tailwind-css-4fg5"&gt;https://dev.to/swyx/how-to-set-up-svelte-with-tailwind-css-4fg5&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/paul42/svelte-tailwind-css-minimal-install-ia2"&gt;https://dev.to/paul42/svelte-tailwind-css-minimal-install-ia2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Required: A Svelte installation&lt;/p&gt;
&lt;h1&gt;
  
  
  Step 1 - Install dependencies
&lt;/h1&gt;

&lt;p&gt;There is a package called &lt;code&gt;svelte-preprocess&lt;/code&gt; that will handle all CSS processing so there is no need to change the npm scripts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -D svelte-preprocess postcss tailwindcss autoprefixer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 2 - Setup configuration files
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;tailwind.config.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// tailwind.config.js
const production = !process.env.ROLLUP_WATCH; // Or some other env var like NODE_ENV
module.exports = {
  future: { // For Tailwind 2.0 upcoming changes
    purgeLayersByDefault: true, 
    removeDeprecatedGapUtilities: true,
  },
  plugins: [],
  purge: {
    content: [
      "./src/**/*.svelte",
      "./public/**/*.html"
    ], 
    enabled: production // Disable purge in dev
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your &lt;code&gt;rollup.config.js&lt;/code&gt; add the import and the other lines in the bottom of the svelte section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sveltePreprocess from "svelte-preprocess";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;svelte({
    // etc...
    preprocess: sveltePreprocess({
        sourceMap: !production,
        postcss: {
            plugins: [
                require("tailwindcss"), 
                require("autoprefixer")
            ],
        },
    }),
}),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 3 - Add the Tailwind styles to the app
&lt;/h1&gt;

&lt;p&gt;Now in your &lt;code&gt;App.svelte&lt;/code&gt; or &lt;code&gt;Layout.svelte&lt;/code&gt; add this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;style global lang="postcss"&amp;gt;
    @tailwind base;
    @tailwind components;
    @tailwind utilities;  
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Acknowledgement
&lt;/h1&gt;

&lt;p&gt;This was heavily influenced by these posts:&lt;br&gt;
&lt;a href="https://dev.to/swyx/how-to-set-up-svelte-with-tailwind-css-4fg5"&gt;https://dev.to/swyx/how-to-set-up-svelte-with-tailwind-css-4fg5&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/paul42/svelte-tailwind-css-minimal-install-ia2"&gt;https://dev.to/paul42/svelte-tailwind-css-minimal-install-ia2&lt;/a&gt;&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>tailwindcss</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
