<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sumit Samanta on Medium]]></title>
        <description><![CDATA[Stories by Sumit Samanta on Medium]]></description>
        <link>https://medium.com/@sumitsamanta?source=rss-530224341a01------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*O5gdEIBd5GV0lKulbh0HWQ.png</url>
            <title>Stories by Sumit Samanta on Medium</title>
            <link>https://medium.com/@sumitsamanta?source=rss-530224341a01------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:24:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sumitsamanta/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular Build Optimisation: A Comprehensive Guide]]></title>
            <link>https://sumitsamanta.medium.com/angular-build-optimisation-a-comprehensive-guide-862a5149df65?source=rss-530224341a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/862a5149df65</guid>
            <category><![CDATA[build]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Sumit Samanta]]></dc:creator>
            <pubDate>Mon, 22 Jul 2024 09:44:15 GMT</pubDate>
            <atom:updated>2024-07-22T09:44:15.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jl4T8CjZa0Bk8al099S-6A.jpeg" /></figure><p>Angular is a powerful framework for building complex web applications. However, as your Angular application grows, you might start to notice that your build times are getting longer and your bundle sizes are growing. This can slow down your development process and negatively impact your users’ experience. In this article, we’ll explore some strategies for optimizing your Angular builds.</p><h3>Understanding Angular Builds</h3><p>Before we dive into optimization strategies, it’s important to understand what happens when you build an Angular application. When you run the ng build command, Angular’s build system, Angular CLI, performs several tasks:</p><ol><li><strong>Compilation</strong>: Angular CLI uses the TypeScript compiler to convert your TypeScript code into JavaScript.</li><li><strong>Bundling</strong>: The JavaScript code is then bundled together using a tool called Webpack.</li><li><strong>Minification</strong>: The bundled code is minified to reduce its size.</li><li><strong>Tree Shaking</strong>: Unused code is removed during a process known as tree shaking.</li></ol><h3>Optimization Strategies</h3><p>Now that we understand what happens during an Angular build, let’s look at some strategies for optimizing your builds.</p><h3>Use the Production Build</h3><p>When you’re ready to deploy your application, always use the production build (ng build --prod). The production build enables several optimizations that are not included in the development build, such as AOT (Ahead-of-Time) compilation, minification, and tree shaking.</p><h3>Enable Lazy Loading</h3><p>Lazy loading is a design pattern that delays the loading of non-critical resources at page load time. In Angular, you can implement lazy loading by using the Angular Router to only load modules when they are needed.</p><h3>Use Angular Universal</h3><p>Angular Universal is a technology that allows you to run your Angular application on the server. This can significantly improve the initial load time of your application.</p><h3>Keep Your Dependencies Up-to-Date</h3><p>Keeping your dependencies up-to-date can also help improve your build times. Newer versions of dependencies often include performance improvements and bug fixes.</p><h3>Conclusion</h3><p>Optimizing your Angular builds can significantly improve your development process and your users’ experience. By understanding how Angular builds work and implementing the strategies discussed in this article, you can ensure that your Angular application is as efficient as possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=862a5149df65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Future of Artificial Intelligence and Its Impact on Society]]></title>
            <link>https://sumitsamanta.medium.com/the-future-of-artificial-intelligence-and-its-impact-on-society-ed26a3e8e107?source=rss-530224341a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed26a3e8e107</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Sumit Samanta]]></dc:creator>
            <pubDate>Mon, 22 Jul 2024 09:33:53 GMT</pubDate>
            <atom:updated>2024-07-22T09:33:53.386Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRW_xrvKzalznfX2nmVMVw.jpeg" /></figure><p>Artificial Intelligence (AI) is no longer a concept confined to science fiction. It’s a reality reshaping our world in ways we could only dream of a few decades ago. But what does the future hold for AI, and how will it impact our society?</p><h3>The Evolution of AI</h3><p>AI has come a long way since its inception. Early AI systems were rule-based and could only perform tasks they were explicitly programmed to do. Today, we have machine learning algorithms that can learn from data and make predictions or decisions without being explicitly programmed to perform the task.</p><p>Deep learning, a subset of machine learning, has taken this a step further. It involves neural networks with several layers (hence the term ‘deep’) that mimic the human brain, enabling the machine to learn from large amounts of data. While a human brain can take a lifetime to learn certain concepts, a deep learning model can learn the same in a matter of minutes or hours.</p><h3>The Impact of AI on Society</h3><p>AI is already having a significant impact on our society. It’s helping doctors diagnose diseases, making our roads safer with autonomous vehicles, and even improving our online shopping experience.</p><p>However, the future of AI promises even more revolutionary changes. Here are a few areas where we can expect to see significant transformations:</p><h3>Healthcare</h3><p>AI has the potential to revolutionize healthcare. From predicting patient risk factors to aiding in drug discovery, AI could save lives and reduce healthcare costs significantly.</p><h3>Education</h3><p>AI could personalize education, adapting learning to the individual needs and pace of each student. This could help students learn more effectively and teachers to better cater to each student’s needs.</p><h3>Environment</h3><p>AI could help us fight climate change by optimizing energy use, predicting weather patterns for more efficient farming, and monitoring deforestation in real time.</p><h3>The Challenges Ahead</h3><p>Despite the potential benefits, AI also presents several challenges. These include job displacement due to automation, privacy concerns, and the risk of AI systems making decisions that humans don’t understand or agree with.</p><p>As we continue to develop and deploy AI, we must address these challenges and ensure that AI benefits all of humanity.</p><h3>Conclusion</h3><p>The future of AI is fascinating. While there are certainly challenges to overcome, the potential benefits far outweigh the risks. As we stand on the brink of this new era, it’s up to us to guide the development of AI in a way that benefits everyone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed26a3e8e107" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Add a Build Number to the Web Build in Angular]]></title>
            <link>https://blog.stackademic.com/how-to-add-a-build-number-to-the-web-build-in-angular-96039e3a35d2?source=rss-530224341a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/96039e3a35d2</guid>
            <category><![CDATA[build-numbers]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[build-version]]></category>
            <dc:creator><![CDATA[Sumit Samanta]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 05:32:44 GMT</pubDate>
            <atom:updated>2023-08-20T10:48:39.025Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Version control" src="https://cdn-images-1.medium.com/max/920/1*8tUajOhK2ZuwA2Sdaz9Z0Q.png" /></figure><p>Have you ever found yourself wondering which version of a web build is running when you deploy your angular code? By adding some scripts to the angular build command I was able to solve this problem.</p><h3><strong>Instructions</strong></h3><p><strong>Step 1 - Adding version in your environment file</strong></p><p>In your <em>environment.ts</em> file, add a version property from the <em>package.json</em></p><pre>export const environment = {<br>  production: true,<br>  version: require(&#39;../../package.json&#39;).version,<br>};</pre><p><strong>Step 2 - Create a build number by using the current time and previous build number</strong></p><p>Create a <em>build-version.js</em> file on the root folder and add the following:</p><pre>const { writeFileSync } = require(&#39;fs&#39;);<br>const { join } = require(&#39;path&#39;);<br><br>const BUILD_VERSION_PATH = join(__dirname, &#39;src/build-version.json&#39;);<br><br>function getTimestampBasedVersion() {<br>  return parseInt(new Date().getTime() / 1000);<br>}<br><br>let currentIteration = getTimestampBasedVersion();<br><br>try {<br>  currentIteration =<br>    require(&#39;./build-version.json&#39;)?.currentIteration ||<br>    getTimestampBasedVersion();<br>} catch (e) {<br>  currentIteration = getTimestampBasedVersion();<br>}<br><br>const buildVersion = {<br>  currentIteration: currentIteration + 1,<br>  buildVersion: `${<br>    require(&#39;./package.json&#39;)?.version<br>  }-build.${currentIteration}`,<br>};<br><br>writeFileSync(BUILD_VERSION_PATH, JSON.stringify(buildVersion, null, 2));</pre><p>This will try to fetch the previous build number from the <em>build-version.json</em> file and increment it by 1, if this file is not found then it will use the current timestamp as the build number.</p><p>The <strong>fs.writeFileSync()</strong> creates a new file if the specified file does not exist.</p><p>The <strong>path</strong>.<strong>join</strong>() method is used to join a number of path-segments using the platform-specific delimiter to form a single path.</p><p>Add <em>build-version.json</em> to the <em>.gitignore</em> file so that it does not create a commit on the build generation.</p><p>If you don’t want the current timestamp as the build number then you can start with 1 as the initial build number.</p><pre>const { writeFileSync } = require(&#39;fs&#39;);<br>const { join } = require(&#39;path&#39;);<br><br>const BUILD_VERSION_PATH = join(__dirname, &#39;src/build-version.json&#39;);<br><br>let currentIteration = 1;<br><br>try {<br>  currentIteration =<br>    require(&#39;./build-version.json&#39;)?.currentIteration || currentIteration;<br>} catch (e) {<br>  currentIteration = 1;<br>}<br><br>const buildVersion = {<br>  currentIteration: currentIteration + 1,<br>  buildVersion: `${<br>    require(&#39;./package.json&#39;)?.version<br>  }-build.${currentIteration}`,<br>};<br><br>writeFileSync(BUILD_VERSION_PATH, JSON.stringify(buildVersion, null, 2));</pre><blockquote>This approach could fail if the deployment creates a new docker image every time, then the build number will always be 1. So in those cases, we can use the current timestamp as the build number.</blockquote><p><strong>Step 3 - Adding bash script to generate the build number</strong></p><p>Create a <em>build-version.sh</em> file and add the following:</p><pre>node build-version.js<br>printf &quot;\n\n&quot;<br>cat src/build-version.json<br>printf &quot;\n\n&quot;</pre><p>This will generate the build version and also print the build number on the console of the docker’s or Jenkin’s console.</p><p><strong>Step 4 - Showing the build number on the web browser</strong></p><p>Add the following code snippet to the <em>app.component.ts</em> to show the build number on the console of the web browser</p><pre>import { Component } from &#39;@angular/core&#39;;<br>import { environment } from &#39;src/environments/environment&#39;;<br>import * as build from &#39;../build-version.json&#39;;<br><br>@Component({<br>  selector: &#39;ra-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.scss&#39;],<br>})<br>export class AppComponent {<br><br>  constructor() {<br>    this.displayBuildVersion();<br>  }<br><br>  /**<br>   * To display the current build version on the console<br>   */<br>  displayBuildVersion(): void {<br>    console.log(<br>      `%cCurrent version: ${environment.version}`,<br>      `background: #0082af; padding: 8px 12px; border-radius: 4px; color: #fafafa; font-size: x-large`<br>    );<br><br>    try {<br>      console.log(<br>        `%cCurrent build number: ${build?.buildVersion}`,<br>        `background: #0082af; padding: 8px 12px; border-radius: 4px; color: #fafafa; font-size: large`<br>      );<br>    } catch (e) {<br>      console.warn(e);<br>    }<br>  }<br>}</pre><p><strong>Step 5 - Running the build version script along with the angular build commands</strong></p><p>Add the build version script <em>build-version.sh</em> to the build commands in the <em>package.json</em></p><pre>{<br>  ...<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;ng&quot;: &quot;ng&quot;,<br>    &quot;start&quot;: &quot;ng serve&quot;,<br>    &quot;build:prod&quot;: &quot;bash build-version.sh &amp;&amp; ng build --configuration production --aot&quot;,<br>    &quot;watch&quot;: &quot;ng build --watch --configuration development&quot;,<br>    &quot;test&quot;: &quot;ng test --code-coverage&quot;,<br>    ...<br>  },<br>  ...<br>}</pre><p><strong>Step 6 - Running your angular build and generating the build number</strong></p><p>Once you run the build and deploy the code on the server you will be able to see the build numbers during the build in docker or Jenkins and also in the deployed website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwlalkX1YjBsjyQNTgCm2Q.png" /><figcaption>Jenkin’s console output showing the current build number</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*glTV79w_v-5Y3o8hWAdCoQ.png" /><figcaption>Web browser’s console log showing the current version and current build number</figcaption></figure><h3><strong>Last thoughts</strong></h3><p>Now you’ve added the build numbers, build again and again to see the build version being incremented on each build.</p><p>Happy coding!</p><p><em>Thank you for reading until the end. Please consider following the writer and this publication. Visit </em><a href="https://stackademic.com/"><strong><em>Stackademic</em></strong></a><em> to find out more about how we are democratizing free programming education around the world.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96039e3a35d2" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/how-to-add-a-build-number-to-the-web-build-in-angular-96039e3a35d2">How to Add a Build Number to the Web Build in Angular</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>