<?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: Oliver Erxleben</title>
    <description>The latest articles on DEV Community by Oliver Erxleben (@olierxleben).</description>
    <link>https://dev.to/olierxleben</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%2F231732%2F71444b70-26c1-4711-a1df-43b9d42124ec.jpeg</url>
      <title>DEV Community: Oliver Erxleben</title>
      <link>https://dev.to/olierxleben</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/olierxleben"/>
    <language>en</language>
    <item>
      <title>Angular + tailwindcss from scratch for the impatient</title>
      <dc:creator>Oliver Erxleben</dc:creator>
      <pubDate>Wed, 30 Sep 2020 21:46:52 +0000</pubDate>
      <link>https://dev.to/olierxleben/angular-tailwindcss-from-scratch-for-the-impatient-2c2k</link>
      <guid>https://dev.to/olierxleben/angular-tailwindcss-from-scratch-for-the-impatient-2c2k</guid>
      <description>&lt;p&gt;There are many tutorials and posts out there about how to setup tailwindcss in an Angular application. Some work, some might not. Here is my log of how to setup, without much tinkering in configs and source code. &lt;/p&gt;

&lt;h1&gt;
  
  
  Setup
&lt;/h1&gt;

&lt;h2&gt;
  
  
  prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;ng&lt;/li&gt;
&lt;li&gt;npm&lt;/li&gt;
&lt;li&gt;node&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lets get started with creating our application&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng new ngtw 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;and choose SCSS for styling lib. After setting up the base application, enter&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev tailwindcss
npm install --save-dev @angular-builders/custom-webpack postcss-scss postcss-import postcss-loader 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Magic lies within the custom-webpack from @angular-builders. We need to configure our project to use that instead of the default one. &lt;/p&gt;

&lt;p&gt;First lets create a useful config. I found many incompatible configs because postcss and web pack seem to be very alive and APIs might change. This one works quite good as the time of writing (30.09.2020). so &lt;/p&gt;

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

&lt;/div&gt;

&lt;p&gt;and enter&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  module: {
    rules: [
      {
       test: /\.scss$/,
       loader: "postcss-loader",
         options: {
           postcssOptions: {
             ident: "postcss",
             syntax: "postcss-scss",
             plugins: [
               require("postcss-import"),
               require("tailwindcss"),
               require("autoprefixer"),
             ],
           },
         },
       },
     ],
   },
 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next step is to tell angular how to use our config. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng config projects.ngtw.architect.build.builder @angular-builders/custom-webpack:browser

ng config projects.ngtw.architect.build.options.customWebpackConfig.path webpack.config.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The first is for the actual builder and the following&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng config projects.ngtw.architect.serve.builder @angular-builders/custom-webpack:dev-server 

ng config projects.ngtw.architect.serve.options.customWebpackConfig.path webpack.config.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;is made for the development server. Now as we have a working webpack configuration setup, it is time to initialize tailwind itself:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tailwind init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The command above will add a &lt;em&gt;tailwind.config.js&lt;/em&gt; to your project. We can leave it as is. &lt;/p&gt;

&lt;p&gt;In the global styles.scss file we need to import Tailwind now:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With this work done you should be able to build angular templates with tailwindcss. Lets build a hello world in app.component.html&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="bg-gray-100 mx-auto my-auto"&amp;gt;&lt;br&gt;
  &amp;lt;h1 class="my-8 text-center text-6xl font-bold"&amp;gt;&lt;br&gt;
    &amp;lt;span class="text-teal-500"&amp;gt;TailwindCSS&amp;lt;/span&amp;gt;&lt;br&gt;
     and&lt;br&gt;
    &amp;lt;span class="text-red-600"&amp;gt;Angular&amp;lt;/span&amp;gt;&lt;br&gt;
     is awesome!&lt;br&gt;
  &amp;lt;/h1&amp;gt;&lt;br&gt;
      &amp;lt;p class="text-center text-3xl"&amp;gt;&lt;br&gt;
        Thanks for reading&lt;br&gt;
      &amp;lt;/p&amp;gt;&lt;br&gt;
&amp;lt;/div&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Review&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;The Post shows in a very very short amount of time how to integrate custom webpack behavior and tailwindcss. Once I saw Flutter and SwiftUI I wanted a similar UI description layer for my very own applications. I make business apps and I am pretty in the web team.&lt;/p&gt;

&lt;p&gt;With tailwind I am a lot more where I want to be. I value much of Angular`s framework or platform thinking and having all familiar options and longevity with me - plus - a nice and well-playing-together abstraction of UI elements I am pretty sure that this will stand some time. &lt;/p&gt;




&lt;p&gt;If you like what you have read or want to discuss, feel free to send and emoji or a comment. Thank you! &lt;/p&gt;

</description>
      <category>angular</category>
      <category>tailwindcss</category>
      <category>setup</category>
    </item>
    <item>
      <title>ng new [in a specific version]</title>
      <dc:creator>Oliver Erxleben</dc:creator>
      <pubDate>Fri, 01 Nov 2019 09:16:20 +0000</pubDate>
      <link>https://dev.to/olierxleben/ng-new-in-a-specific-version-3h8j</link>
      <guid>https://dev.to/olierxleben/ng-new-in-a-specific-version-3h8j</guid>
      <description>&lt;p&gt;Ever wanted to test out an angular application from a beta version or a release candidate but&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng new [project]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;does always use the latest stable? And &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng new --help
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;doesen`t show up a param to specify a version?&lt;/p&gt;

&lt;p&gt;Yeah. Exactly what happened to me. In the post I will share how to do that. &lt;/p&gt;

&lt;h1&gt;
  
  
  Short Story for the busy devs like me
&lt;/h1&gt;

&lt;p&gt;npm version used: 6.12.1&lt;br&gt;
node version used: v12.12.0&lt;/p&gt;

&lt;p&gt;You simply install a specific @angular/cli package using npm (or yarn?). I tested with npm to install angular 9rc:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir angular-9rc
cd angular-9rc
npm install @angular/cli@next
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;where "next" could be a specific older version or a beta tag you will find on npmjs.com: &lt;a href="https://www.npmjs.com/package/@angular/cli"&gt;https://www.npmjs.com/package/@angular/cli&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that you are able to use the local installed version using just&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng new HelloNine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Installation takes quite some time. After all I was able to run the app as usual with &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng serve
ng build
ng build --prod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;So with ivy enabled by default? Following documentation: yes it is. Have a look here: &lt;a href="https://next.angular.io/guide/ivy"&gt;https://next.angular.io/guide/ivy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;the &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng build --prod 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;results in &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wW2_WWD1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lyapdlanqxld5xc4i8ra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wW2_WWD1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/lyapdlanqxld5xc4i8ra.png" alt="Results in FireFox" width="880" height="134"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That`s okay, but I think Ivy could get a way smaller. Thanks for reading! &lt;/p&gt;

</description>
      <category>angular</category>
      <category>cli</category>
      <category>ng</category>
    </item>
  </channel>
</rss>
