<?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: Benson Mwaura</title>
    <description>The latest articles on DEV Community by Benson Mwaura (@bensonmwaura).</description>
    <link>https://dev.to/bensonmwaura</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%2F203807%2Fdc6e3929-454b-4e28-943a-8cc894198159.jpeg</url>
      <title>DEV Community: Benson Mwaura</title>
      <link>https://dev.to/bensonmwaura</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bensonmwaura"/>
    <language>en</language>
    <item>
      <title>How to integrate shadcn-svelte into the editable.website template</title>
      <dc:creator>Benson Mwaura</dc:creator>
      <pubDate>Mon, 14 Oct 2024 08:39:39 +0000</pubDate>
      <link>https://dev.to/bensonmwaura/how-to-integrate-shadcn-svelte-into-the-editablewebsite-template-91h</link>
      <guid>https://dev.to/bensonmwaura/how-to-integrate-shadcn-svelte-into-the-editablewebsite-template-91h</guid>
      <description>&lt;p&gt;Follow these steps to integrate &lt;a href="https://www.shadcn-svelte.com/" rel="noopener noreferrer"&gt;shadcn-svelte&lt;/a&gt; into the &lt;a href="https://editable.website/" rel="noopener noreferrer"&gt;editable.website&lt;/a&gt; template. This guide assumes you have a basic understanding of SvelteKit and &lt;a href="https://Node.js" rel="noopener noreferrer"&gt;Node.js.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Set Up Your Project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Clone the **&lt;a href="https://Editable.Website" rel="noopener noreferrer"&gt;Editable.Website&lt;/a&gt;&lt;/strong&gt; Template**: Start by cloning the &lt;code&gt;editable.website&lt;/code&gt; repository to your local machine:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/michael/editable-website.git
cd editable-website
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Install Dependencies&lt;/strong&gt;: Install the necessary dependencies for your project:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 2: Create Environment Variables
&lt;/h3&gt;

&lt;p&gt;Copy &lt;code&gt;.env.example&lt;/code&gt; to &lt;code&gt;.env&lt;/code&gt; and configure your database and admin password.&lt;/p&gt;




&lt;h3&gt;
  
  
  Step 3: Seed the Database
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: Make sure you have &lt;code&gt;sqlite3&lt;/code&gt; installed on your system. If not, you can install it from &lt;a href="https://www.sqlite.org/download.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Seed your database using:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sqlite3 data/db.sqlite3 &amp;lt; sql/schema.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 4: Run the Development Server
&lt;/h3&gt;

&lt;p&gt;bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 5: Create a  &lt;a href="https://jsconfig.json" rel="noopener noreferrer"&gt;jsconfig.json&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Since the &lt;a href="https://editable.website" rel="noopener noreferrer"&gt;editable.website&lt;/a&gt;seems to be opted-out of TypeScript, to configure import aliases, create a &lt;code&gt;jsconfig.json&lt;/code&gt; file:  &lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch jsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;a href="https://jsconfig.json" rel="noopener noreferrer"&gt;jsconfig.json&lt;/a&gt;&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "compilerOptions": {
        "paths": {
          "$lib/*": ["./src/lib/*"]
        }
      }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 6: Setup Path Aliases
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you are not using the default alias &lt;code&gt;$lib&lt;/code&gt;, update your &lt;code&gt;svelte.config.js&lt;/code&gt; file to include those aliases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://svelte.config.js" rel="noopener noreferrer"&gt;svelte.config.js&lt;/a&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const config = {
      // ... other config
      kit: {
        // ... other config
        alias: {
          $lib: "src/lib",
          "$lib/*": "src/lib/*",
          $components: "src/lib/components",
          "$components/*": "src/lib/components/*",
          $utils: "src/lib/utils",
          "$utils/*": "src/lib/utils/*"
        }
      }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 7: Install Compatible Prettier Version
&lt;/h3&gt;

&lt;p&gt;To fix the warning about peer dependencies for &lt;code&gt;prettier-plugin-tailwindcss&lt;/code&gt; and &lt;code&gt;prettier-plugin-svelte&lt;/code&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Install Compatible Prettier Versions&lt;/strong&gt;: Create a new dev dependency using a compatible version for &lt;code&gt;svelte&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm install --save-dev prettier@^2.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Use *&lt;/em&gt;&lt;code&gt;npm alias&lt;/code&gt;: This allows you to install multiple versions of Prettier:&lt;br&gt;
bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm install --save-dev prettier-2@npm:prettier@^2.0.0 prettier-3@npm:prettier@^3.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Adjust Scripts&lt;/strong&gt;: Update your npm scripts in &lt;code&gt;package.json&lt;/code&gt; to use the specific Prettier versions:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://package.json" rel="noopener noreferrer"&gt;package.json&lt;/a&gt;&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
      "format:svelte": "prettier-2 --write 'src/**/*.{js,svelte}'",
      "format:other": "prettier-3 --write 'src/**/*.{js,ts,css,md,json}'"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 8: Run the CLI
&lt;/h3&gt;

&lt;p&gt;bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm dlx shadcn-svelte@latest init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Step 9: Configure  &lt;a href="https://components.json" rel="noopener noreferrer"&gt;components.json&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;You will be asked a few questions to configure &lt;code&gt;components.json&lt;/code&gt;:&lt;br&gt;&lt;br&gt;
bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      Would you like to use TypeScript (recommended)? › Yes
      Which style would you like to use? › Default
      Which color would you like to use as base color? › Slate
      Where is your global CSS file? › src/app.css
      Where is your tailwind.config.[cjs|js|ts] located? › tailwind.config.js
      Configure the import alias for components: › $lib/components
      Configure the import alias for utils: › $lib/utils
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  That's It
&lt;/h3&gt;

&lt;p&gt;You can now start adding components to your project.&lt;br&gt;&lt;br&gt;
bash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm dlx shadcn-svelte@latest add button
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command above will add the Button component to your project. You can then import it like this:  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;svelte&lt;/em&gt;&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;script lang="ts"&amp;gt;
      import { Button } from "$lib/components/ui/button";
      &amp;lt;/script&amp;gt;

      &amp;lt;Button&amp;gt;Click me&amp;lt;/Button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;This guide should provide a solid foundation for integrating &lt;code&gt;shadcn-svelte&lt;/code&gt; into the &lt;code&gt;editable.website&lt;/code&gt; template. If you have any specific questions or need further assistance, feel free to checkout the docs for &lt;a href="https://www.shadcn-svelte.com/docs" rel="noopener noreferrer"&gt;shadcn-svelte&lt;/a&gt; and the &lt;a href="https://github.com/michael/editable-website" rel="noopener noreferrer"&gt;editable.website&lt;/a&gt; repo.&lt;/p&gt;

</description>
      <category>sveltekit</category>
    </item>
  </channel>
</rss>
