<?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: Lucas Melo</title>
    <description>The latest articles on DEV Community by Lucas Melo (@lucasmelo).</description>
    <link>https://dev.to/lucasmelo</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%2F725768%2F73e72ff0-b1c4-445d-97c5-bb7bea3acbc8.JPG</url>
      <title>DEV Community: Lucas Melo</title>
      <link>https://dev.to/lucasmelo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lucasmelo"/>
    <language>en</language>
    <item>
      <title>10 heurísticas de Nielsen aplicadas a engenharia de software</title>
      <dc:creator>Lucas Melo</dc:creator>
      <pubDate>Wed, 14 May 2025 23:48:35 +0000</pubDate>
      <link>https://dev.to/lucasmelo/10-heuristicas-de-nielsen-aplicadas-a-engenharia-de-software-25g0</link>
      <guid>https://dev.to/lucasmelo/10-heuristicas-de-nielsen-aplicadas-a-engenharia-de-software-25g0</guid>
      <description>&lt;p&gt;recentemente tenho estudado mais sobre ux porque acredito que para nós, pessoas que constroem produtos, o usuário deve ser o foco em todos os processos.&lt;/p&gt;

&lt;p&gt;e não, isso não é só uma responsabilidade do time de design/produto. nós, principalmente desenvolvedores, devemos ser questionadores e provocadores em vez de só reproduzir uma tela ou api com funcionalidades já decididas. existem pequenos detalhes que nem sempre vão estar presentes nos requisitos/design e nós podemos adicionar para enriquecer a experiência (pop-ups, regras de negócio, textos adicionais...)&lt;/p&gt;

&lt;p&gt;as heurísticas de Nielsen são princípios fundamentais de usabilidade que, quando aplicados ao desenvolvimento de software podem transformar melhorar experiência do usuário. estes princípios não são apenas teóricos, mas ferramentas práticas que podemos adicionar ao nosso conhecimento e dia a dia. confesso que várias coisas conhecemos inconscientemente, vou exemplificar como cada uma delas pode ser aplicada a situações reais:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jrw2vv1bnu94wgz7tj4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3jrw2vv1bnu94wgz7tj4.png" alt="10 heurísticas" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  1. visibilidade do status do sistema
&lt;/h4&gt;

&lt;p&gt;quando um usuário interage com uma aplicação de e-commerce e adiciona um produto ao carrinho, é essencial que ele receba confirmação visual imediata. podemos adicionar uma animação no carrinho, um contador atualizado ou uma notificação de sucesso. isso não é só estético, mas funcional, pois reduz a ansiedade do usuário e evita que ele adicione o mesmo produto múltiplas vezes por incerteza.&lt;/p&gt;

&lt;p&gt;quando eu criei meu primeiro portfólio por conta própria, criei uma seção que me enviava um e-mail mas não implementei um feedback visual de que havia sido enviado. resultado: um usuário mandou o mesmo e-mail 20 vezes. nunca mais esqueci de retornar feedbacks&lt;/p&gt;

&lt;h4&gt;
  
  
  2. correspondência entre o sistema e o mundo real
&lt;/h4&gt;

&lt;p&gt;no desenvolvimento de um aplicativo de notas, em vez de criar uma estrutura organizacional puramente digital e abstrata, podemos implementar uma metáfora de cadernos e páginas. o Notion faz isso muito bem, permitindo que os usuários organizem seu conteúdo em páginas e subpáginas que se comportam como documentos físicos, mas com a flexibilidade adicional do meio digital.&lt;/p&gt;

&lt;p&gt;para um aplicativo financeiro, termos como "extrato" e "saldo" são mais eficazes que "log de transações" ou "valor líquido atual". &lt;br&gt;
devemos priorizar a simplicidade e familiaridade nas terminologias e fluxos, sempre focando no público-alvo.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. controle e liberdade do usuário
&lt;/h4&gt;

&lt;p&gt;em aplicações de edição colaborativa como o Figma, a implementação de histórico de ações dá aos usuários a liberdade de explorar diferentes abordagens de design sabendo que podem voltar atrás.&lt;/p&gt;

&lt;p&gt;mais importante que só construir funcionalidades é: dar confiança para os usuários de que aquela aplicação oferece controle das próprias ações. possibilidade de reverter ações e voltar atrás. uma segurança psicológica que o controle proporciona.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. consistência e padrões
&lt;/h4&gt;

&lt;p&gt;ter padrões no produto (ou família de produtos) faz com que o usuário utilize sistemas de maneira previsível. esta consistência reduz significativamente a carga cognitiva dos usuários.&lt;/p&gt;

&lt;p&gt;é um ótimo exemplo do quão importante é ter uma biblioteca de componentes que, além de bonito esteticamente, tem valor funcional. um botão primário deve parecer e se comportar da mesma forma em toda a aplicação, independentemente do desenvolvedor que o implementou.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. prevenção de erros
&lt;/h4&gt;

&lt;p&gt;em um sistema de reservas online, podemos evitar conflitos implementando validações em tempo real. por exemplo, ao selecionar datas para hospedagem, o sistema pode desabilitar automaticamente datas indisponíveis ou mostrar visualização de preços conforme o usuário faz sua seleção.&lt;/p&gt;

&lt;p&gt;podemos e devemos antecipar os possíveis erros e criar sistemas que os previnam proativamente, em vez de apenas tratá-los depois que ocorrem. parece bobo, mas afeta o número de chamadas a api, performance, custos.&lt;/p&gt;

&lt;h4&gt;
  
  
  6. reconhecimento em vez de lembrança
&lt;/h4&gt;

&lt;p&gt;esse exemplo vi num vídeo do youtube e foi sensacional. pense nessas duas frases: "Lisboa é a capital de Portugal?" e "Qual é a capital de Portugal?"&lt;/p&gt;

&lt;p&gt;a primeira te traz um reconhecimento e você consegue validar aquele conhecimento facilmente. a segunda faz com que você precise pensar qual é a capital daquele país.&lt;/p&gt;

&lt;p&gt;sempre devemos optar por export opções e informações contextualmente relevantes, reduzindo a carga de memória e tornando a navegação mais intuitiva.&lt;/p&gt;

&lt;h4&gt;
  
  
  7. flexibilidade e eficiência de uso
&lt;/h4&gt;

&lt;p&gt;o VS Code oferece múltiplas formas de realizar a mesma tarefa: menus, atalhos de teclado ou comandos rápidos (Ctrl+P). isso permite que iniciantes explorem visualmente enquanto usuários experientes utilizam métodos mais eficientes, sem sacrificar funcionalidades.&lt;/p&gt;

&lt;p&gt;ofereça opções para o usuário escolher como prefere&lt;/p&gt;

&lt;h4&gt;
  
  
  8. design estético e minimalista
&lt;/h4&gt;

&lt;p&gt;óbvio que uma interface ser bonita importa, mas a hierarquia visual ainda precisa prevalecer. informações secundárias não devem competir com informações principais. tirando o foco do usuário do que realmente importa.&lt;/p&gt;

&lt;p&gt;sabe aqueles sites que parece que você tá tendo uma experiência que tá numa grande feira e não sabe pra onde olhar? exatamente isso.&lt;/p&gt;

&lt;h4&gt;
  
  
  9. ajuda aos usuários para reconhecer, diagnosticar e recuperar-se de erros
&lt;/h4&gt;

&lt;p&gt;um bom exemplo é o caso de um filtro aplicado que não tem resultados. uma tela de erro 404... as alternativas para lidar com o erro devem sempre ser pensadas.&lt;/p&gt;

&lt;p&gt;a api respondeu 500? que tal colocar um botão de tentar de novo? não podemos previnir todos os erros, mas devemos fazer com que o usuário lide com eles da melhor maneira possível.&lt;/p&gt;

&lt;h4&gt;
  
  
  10. ajuda e documentação
&lt;/h4&gt;

&lt;p&gt;telas de documentação, faq, chatbots, onboardings... isso tudo faz com que o usuário tenha acesso a documentação de forma mais eficaz que manuais extensos separados da interface.&lt;/p&gt;

&lt;p&gt;o usuário precisa compreender o que estamos criando.&lt;/p&gt;




&lt;p&gt;eu sei que é chato pensar em tantos casos de uso quando estamos desenvolvendo coisas simples, mas isso torna uma aplicação mais completa, intuitiva e profissional. &lt;/p&gt;

&lt;p&gt;e tem um ganho quase que "invisível": reduz custos de suporte, aumenta a satisfação do usuário e, ultimamente, diferencia nossos produtos em um mercado competitivo. &lt;/p&gt;

&lt;p&gt;crie produtos para humanos (principalmente o seu público alvo), não produtos para provar conceitos técnicos :)&lt;/p&gt;

</description>
      <category>ux</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Migrating from Create React App to Vite (with a bonus to Vitest)</title>
      <dc:creator>Lucas Melo</dc:creator>
      <pubDate>Wed, 26 Feb 2025 03:09:35 +0000</pubDate>
      <link>https://dev.to/lucasmelo/migrating-from-create-react-app-to-vite-with-a-bonus-to-vitest-5hi7</link>
      <guid>https://dev.to/lucasmelo/migrating-from-create-react-app-to-vite-with-a-bonus-to-vitest-5hi7</guid>
      <description>&lt;p&gt;Hey there! 👋 If you’ve been using Create React App (CRA) for your React projects, you might have heard the news: CRA is now deprecated. While it’s not disappearing overnight, it’s no longer receiving updates, which means it’s time to consider moving to a more modern tool. That’s where Vite comes in a fast and efficient build tool.&lt;/p&gt;

&lt;p&gt;In this guide, I’ll walk you through migrating your project from CRA to Vite. Let’s get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should You Migrate to Vite?
&lt;/h2&gt;

&lt;p&gt;Before we dive into the migration steps, let’s talk about why Vite is worth considering:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Speed:&lt;/strong&gt; Vite uses modern ES Modules and esbuild, which means your dev server starts up almost instantly, and hot reloads are lightning-fast.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Modern Tooling:&lt;/strong&gt; Vite is built with the latest web standards, so you’re not just keeping up—you’re staying ahead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Simplicity:&lt;/strong&gt; Vite’s configuration is minimal and straightforward, making it easier to set up and maintain compared to CRA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Security:&lt;/strong&gt; since CRA is deprecated, it won’t receive security updates. Migrating to Vite ensures your project stays secure and up-to-date.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Better Developer Experience:&lt;/strong&gt; from faster builds to a more intuitive setup, Vite makes development smoother and more enjoyable.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Risks of Staying with CRA
&lt;/h2&gt;

&lt;p&gt;Sticking with a deprecated tool like CRA isn’t just inconvenient, it can also pose risks:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- Security Vulnerabilities:&lt;/strong&gt; without updates, your project could become vulnerable to security issues.&lt;br&gt;
&lt;strong&gt;- Lack of Support:&lt;/strong&gt; you won’t have access to new features, bug fixes, or community support.&lt;br&gt;
&lt;strong&gt;- Compatibility Issues:&lt;/strong&gt; over time, CRA might not work well with newer libraries or dependencies.&lt;br&gt;
&lt;strong&gt;- Technical Debt:&lt;/strong&gt; delaying the migration will only make it harder to switch later.&lt;/p&gt;

&lt;p&gt;Migrating to Vite isn’t just about keeping up with trends, it’s about ensuring your project remains secure, maintainable, and future-proof.&lt;/p&gt;


&lt;h2&gt;
  
  
  Step-by-Step Migration Guide
&lt;/h2&gt;

&lt;p&gt;Let’s walk through the process of migrating your project from CRA to Vite.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Back Up Your Project
&lt;/h3&gt;

&lt;p&gt;Before making any changes, make sure to back up your project. It’s always better to be safe!&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Remove CRA and Install Vite
&lt;/h3&gt;

&lt;p&gt;First, let’s remove CRA and install Vite. Run these commands in your project’s root directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm uninstall react-scripts # Removes CRA
npm install vite @vitejs/plugin-react --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This removes react-scripts (the core of CRA) and installs Vite along with its React plugin.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Create a vite.config.js File
&lt;/h3&gt;

&lt;p&gt;Next, create a vite.config.js file in the root of your project. This is where you’ll configure Vite. Here’s a basic setup to get you started:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Update Your package.json Scripts
&lt;/h3&gt;

&lt;p&gt;Now, update the scripts in your package.json to use Vite:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "start": "vite",
  "build": "vite build",
  "serve": "vite preview"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Move and Update Your index.html
&lt;/h3&gt;

&lt;p&gt;In CRA, your index.html file is located in the public folder. With Vite, it needs to be moved to the root of your project. You’ll also need to update any references to %PUBLIC_URL%. Here’s an example:&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;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
    &amp;lt;title&amp;gt;My React App&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="root"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;script type="module" src="/src/index.jsx"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how %PUBLIC_URL% is gone? Vite handles paths differently, so you can use relative paths like /favicon.ico instead. I received a lot of errors because I forgot to change this.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Check Your Imports and File Extensions
&lt;/h3&gt;

&lt;p&gt;Vite uses ES Modules by default, so double-check your imports to ensure they’re correct. If you’re using JSX, rename your .js files to .jsx (or .tsx for TypeScript).&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Start the Dev Server
&lt;/h3&gt;

&lt;p&gt;Once everything’s in place, start your dev server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If all goes well, you should see your app running smoothly with Vite. 🎉&lt;/p&gt;




&lt;h2&gt;
  
  
  Bonus: Migrating to Vitest for Testing
&lt;/h2&gt;

&lt;p&gt;If you’re using Jest for testing, you’ll appreciate Vitest. It’s built by the Vite team and is designed to work seamlessly with Vite. Plus, it’s fast and lightweight. Here’s how to make the switch.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Install Vitest
&lt;/h3&gt;

&lt;p&gt;First, add Vitest to your project:&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 vitest --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Configure Vitest
&lt;/h3&gt;

&lt;p&gt;Update your vite.config.js to include Vitest’s configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
  test: {
    globals: true,
    environment: 'jsdom',
  },
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Update Your Test Scripts
&lt;/h3&gt;

&lt;p&gt;In your package.json, replace your Jest scripts with these:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "test": "vitest",
  "coverage": "vitest run --coverage"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.Migrate Your Tests
&lt;/h3&gt;

&lt;p&gt;Most Jest tests will work in Vitest without any changes. If you’re using Jest-specific functions like jest.mock, Vitest has you covered—just replace jest with vi:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { vi, expect, test } from 'vitest';

test('example test', () =&amp;gt; {
  vi.mock('./myModule');
  expect(1 + 1).toBe(2);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Run Your Tests
&lt;/h3&gt;

&lt;p&gt;Finally, run your tests to make sure everything’s working:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  That's all 👋
&lt;/h2&gt;

&lt;p&gt;Migrating from Create React App to Vite is a smart move for any React project. You’ll benefit from faster builds, a better development experience, and the peace of mind that comes with using a modern, actively maintained tool. Plus, with Vitest, your tests will run faster and more efficiently.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to deploy affected NX projects to AWS S3 using Github Actions</title>
      <dc:creator>Lucas Melo</dc:creator>
      <pubDate>Mon, 21 Oct 2024 18:53:31 +0000</pubDate>
      <link>https://dev.to/lucasmelo/how-to-deploy-affected-nx-projects-to-aws-s3-using-github-actions-1f70</link>
      <guid>https://dev.to/lucasmelo/how-to-deploy-affected-nx-projects-to-aws-s3-using-github-actions-1f70</guid>
      <description>&lt;p&gt;First of all, if you don’t know what Nx Workspaces is, I recommend checking it out and learning more! It’s a great tool, especially for monorepos.&lt;/p&gt;

&lt;p&gt;In this section of the &lt;a href="https://nx.dev/getting-started/tutorials/react-monorepo-tutorial#building-the-apps-for-deployment" rel="noopener noreferrer"&gt;tutorial&lt;/a&gt;, we have an example of how to deploy an application to Netlify.&lt;/p&gt;

&lt;p&gt;In this tutorial, I’ve brought details on how to deploy to AWS S3 using GitHub Actions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a bucket on S3 with all the necessary configurations for a public page.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;2. Set up a role for your application to have permission to modify the bucket’s content.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;3. Continue setting up your &lt;code&gt;ci.yml&lt;/code&gt; file. I used the following configuration:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Remember to update your &lt;em&gt;AWS credentials&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;name: CI

on:
  push:
    branches: [main]

permissions:
  id-token: write
  actions: read
  contents: read

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      # Cache node_modules
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: 'npm'
      - run: npm ci --legacy-peer-deps
      - uses: nrwl/nx-set-shas@v4

      - run: npx nx affected -t test build build-storybook

      - name: Install AWS CLI
        uses: unfor19/install-aws-cli-action@v1
        with:
          version: 1

      - name: Configure aws credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: &amp;lt;ROLE&amp;gt;
          role-session-name: &amp;lt;ROLE_NAME&amp;gt;
          aws-region: &amp;lt;AWS_REGION&amp;gt;

      - uses: nrwl/nx-set-shas@v4
      - run: npx nx affected -t deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this configured, all affected applications that have the deploy command will be running. Now, let’s create the deploy command for the applications.&lt;/p&gt;

&lt;p&gt;Go to your application's &lt;code&gt;project.json&lt;/code&gt; and add the new command. &lt;br&gt;
You need to locate the folder where the build is generated (in my case, &lt;code&gt;dist/apps/&lt;/code&gt;) and the bucket where the upload will be done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"targets": {
    "deploy": {
      "executor": "nx:run-commands",
      "options": {
        "command": "aws s3 sync dist/apps/&amp;lt;YOUR APP&amp;gt; s3://&amp;lt;BUCKET_NAME&amp;gt;/ --delete"
      }
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this, the deployment of affected applications should work perfectly. This tutorial could have saved me a few hours of research looking for a way to do this.&lt;/p&gt;

&lt;p&gt;Thank you for reading ;)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>aws</category>
      <category>githubactions</category>
      <category>nx</category>
    </item>
    <item>
      <title>Boosting Performance by Removing Unused Files and Dependencies with Knip and PurgeCSS</title>
      <dc:creator>Lucas Melo</dc:creator>
      <pubDate>Sat, 05 Oct 2024 15:18:00 +0000</pubDate>
      <link>https://dev.to/lucasmelo/boosting-performance-by-removing-unused-files-and-dependencies-with-knip-and-purgecss-1dm1</link>
      <guid>https://dev.to/lucasmelo/boosting-performance-by-removing-unused-files-and-dependencies-with-knip-and-purgecss-1dm1</guid>
      <description>&lt;p&gt;As developers, we're constantly striving for better performance. Whether it's faster load times, more responsive UIs, or smaller bundle sizes, performance is a key metric that directly impacts user experience. One overlooked area that can significantly improve performance is cleaning up unused files and dependencies. In this article, I’ll explore how identifying and removing dead code, unused packages, and unnecessary CSS can lead to a leaner, faster project. We'll also take a look at how tools like Knip and PurgeCSS can help automate this process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Cleaning Up Unused Code Matters
&lt;/h2&gt;

&lt;p&gt;Over time, it's easy for projects to accumulate unnecessary files, dependencies, and CSS rules that are no longer in use. These leftovers bloat your project, making it slower to load, harder to maintain, and potentially impacting performance in ways you don’t immediately realize.&lt;/p&gt;

&lt;p&gt;By regularly removing unused code, you not only shrink the size of your JavaScript bundles and CSS files but also improve load times, reduce memory usage, and decrease the overall footprint of your application. This practice is especially critical for front-end performance, where every kilobyte counts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools for the Job: Knip and PurgeCSS
&lt;/h2&gt;

&lt;p&gt;Now that we understand the importance of keeping a project tidy, let’s briefly discuss the tools we can use to automate this process. Knip is a tool designed to analyze your JavaScript project and identify unused dependencies and files, while PurgeCSS focuses on cleaning up unused CSS classes from your stylesheets. Together, these tools help ensure that only the code you're actually using makes it to production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Improving Performance: The Workflow
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Audit Your Dependencies with Knip
The first step to cleaning up your project is auditing your dependencies and modules. Knip scans your project, analyzes the imports, and provides a report of what's in use and what can be safely removed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Instalation and Setup&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init @knip/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Running&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Knip generates a report highlighting unused dependencies and files. This allows you to quickly identify which parts of your project are no longer necessary, helping you reduce bundle size and improve performance.&lt;/p&gt;

&lt;p&gt;Example output&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkucodz3et2521d5fm1x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxkucodz3et2521d5fm1x.png" alt="List of unused files"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this summary, you can safely review your files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Optimize Your CSS with PurgeCSS&lt;/strong&gt;&lt;br&gt;
CSS, just like JavaScript, can become bloated over time. PurgeCSS is a tool that removes unused CSS selectors from your stylesheets, ensuring that your project only ships the necessary styles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instalation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i -D @fullhuman/postcss-purgecss postcss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Run PurgeCSS CLI in postbuild&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I prefer using it as a post-build script, but you can configure the command for any file you need. Simply specify your build folder and the path to the script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
      "postbuild": "purgecss --css dist/assets/*.css --content dist/index.html dist/assets/*.js --output dist/assets"
},
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this setup, PurgeCSS will automatically strip away unused CSS classes, leaving you with a much smaller and optimized stylesheet.&lt;br&gt;
Checkout PurgeCSS docs to more details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Regularly Review and Refactor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While tools like Knip and PurgeCSS automate a large part of the cleanup process, regular reviews of your codebase are still essential. Make it a habit to refactor old code, remove unused components, and ensure that your project remains lightweight and easy to maintain. Automating this process with CI/CD pipelines can also help you keep your codebase lean and performant as you continue developing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Improving the performance of your application isn’t just about writing efficient code; it’s also about keeping your project clean and free of unnecessary files and dependencies. Regularly removing unused code not only reduces the size of your project but also improves load times, simplifies maintenance, and enhances the user experience. Tools like Knip and PurgeCSS make it easier to automate this cleanup process, but the key takeaway is the habit of constantly auditing and optimizing your code.&lt;/p&gt;

&lt;p&gt;By adopting this mindset and utilizing these tools, you can ensure your project remains fast, lean, and optimized for the best performance possible.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>performance</category>
      <category>css</category>
    </item>
    <item>
      <title>How to setup Cypress environment with Typescript</title>
      <dc:creator>Lucas Melo</dc:creator>
      <pubDate>Wed, 09 Feb 2022 16:31:16 +0000</pubDate>
      <link>https://dev.to/lucasmelo/how-to-setup-cypress-environment-with-typescript-1650</link>
      <guid>https://dev.to/lucasmelo/how-to-setup-cypress-environment-with-typescript-1650</guid>
      <description>&lt;p&gt;Testing is always the best way to make sure that everything in your application is working as it should (even after fixes or new features). &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Unit&lt;/em&gt; tests are so useful, but when it comes to testing a whole flow or bigger functionalities, &lt;em&gt;end-to-end&lt;/em&gt; tests are most suitable. In this tutorial, I will help you to setup a Cypress environment with Typescript, create custom commands and use Cypress Testing Library.&lt;/p&gt;

&lt;h3&gt;
  
  
  Install
&lt;/h3&gt;

&lt;p&gt;First, you should add cypress to the application you want.&lt;/p&gt;

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

yarn add cypress --dev


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(or with npm, if you prefer)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, we still need open it for the first time to config. You need to add a new script in your &lt;code&gt;package.json&lt;/code&gt; and &lt;strong&gt;run&lt;/strong&gt; in your terminal. It's very important to run, because it will generate a lot of files in your app.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;root/package.json&lt;/em&gt;&lt;/p&gt;

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

"cy:open": "cypress open"


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will open the cypress interface and create a &lt;em&gt;cypress folder&lt;/em&gt; and &lt;em&gt;cypress.json file&lt;/em&gt;. As you can see, there are some example tests (&lt;em&gt;in cypress/integration&lt;/em&gt;) and a lot of default configs. &lt;em&gt;cypress/integration&lt;/em&gt; is the folder you can create your tests.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Config
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Typescript
&lt;/h4&gt;

&lt;p&gt;The first thing we need to do is creating a &lt;code&gt;tsconfig.json&lt;/code&gt; file &lt;strong&gt;inside&lt;/strong&gt; the cypress folder and paste this&lt;/p&gt;

&lt;p&gt;&lt;em&gt;cypress/tsconfig.json&lt;/em&gt;&lt;/p&gt;

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

{
    "compilerOptions": {
        "target": "ES5",
        "lib": ["es5", "dom"],
        "types": ["cypress"]
    },
    "include": ["**/*.ts"]
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;At this time, you should restart your Typescript server. If you're in VSCode just type:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ctrl + shift + P&lt;/li&gt;
&lt;li&gt;restart TS server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In cypress/support folder, you see &lt;em&gt;commands.js file&lt;/em&gt; and &lt;em&gt;index.js file&lt;/em&gt;. Rename to typescript extension. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;cypress/support&lt;/em&gt;&lt;/p&gt;

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

commands.js -&amp;gt; commands.ts
index.js -&amp;gt; index.ts


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Create an &lt;em&gt;index.d.ts file&lt;/em&gt; in this same folder (cypress/support). This will be important to create custom commands - very useful!. Add this to index.d.ts file:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;cypress/support/index.d.ts&lt;/em&gt;&lt;/p&gt;

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

/// &amp;lt;reference types="cypress" /&amp;gt;

declare namespace Cypress {
    interface Chainable {

    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, we have to update root/tsconfig.json by adding "cypress" to exclude.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;root/tsconfig.json&lt;/em&gt;&lt;/p&gt;

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

"exclude": ["cypress", "node_modules"]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The config is almost done, now, we just have to this to the root/cypress.json&lt;/p&gt;

&lt;p&gt;&lt;em&gt;cypress.json&lt;/em&gt;&lt;/p&gt;

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

{
    "video": false,
    "baseUrl": "http://localhost:3000"
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Testing Library
&lt;/h4&gt;

&lt;p&gt;Once we configured Typescript, now it's time to add improve our environment. First, we need to add the Cypress Testing Library. It allows us to use commands from testing library.&lt;/p&gt;

&lt;p&gt;Just run in your terminal&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

yarn add @testing-library/cypress @types/cypress jest @types/jest -D 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After this, is necessary to add these commands to our environment. Add this to the commands.ts file.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;cypress/support/commands.ts&lt;/em&gt;&lt;/p&gt;

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

import "@testing-library/cypress/add-commands";


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And add this line to the cypress/tsconfig.json file, so it can identify the library.&lt;/p&gt;

&lt;p&gt;cypress/tsconfig.json&lt;/p&gt;

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

"types": ["cypress", "@testing-library/cypress"]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Creating custom commands
&lt;/h4&gt;

&lt;p&gt;This is actually the most cool thing, in my opinion, about Cypress. We can create custom commands like: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;cy.google() - and then the test visit the google page&lt;/em&gt;&lt;br&gt;
&lt;em&gt;cy.login() - and then you login in your application&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Literally anything you want. What we always need to do is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the command in &lt;em&gt;cypress/support/commands.ts&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Type the command in &lt;em&gt;cypress/support/index.d.ts&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Sometimes, error may be generated, just restart TS server and everything is ok again.&lt;/p&gt;

&lt;p&gt;Let's create our first command: cy.google() will visit google.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;cypress/support/commands.ts&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import "@testing-library/cypress/add-commands";

Cypress.Commands.add("google", () =&amp;gt; cy.visit("https://www.google.com"));


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Typing our new command&lt;br&gt;
&lt;em&gt;cypress/support/index.d.ts&lt;/em&gt;&lt;/p&gt;

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

/// &amp;lt;reference types="cypress" /&amp;gt;

declare namespace Cypress {
    interface Chainable {
        /**
         * Custom command to visit google page
         * @example cy.google()
         */
        google (): Chainable&amp;lt;Window&amp;gt;
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now you can use cy.google() in any test you want :)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's create an example test.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create an &lt;em&gt;example.ts&lt;/em&gt; file in &lt;em&gt;cypress/integration&lt;/em&gt; folder.&lt;/p&gt;

&lt;p&gt;Since we're using custom commands, we need to reference in &lt;strong&gt;every test file!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is my example.ts file:&lt;/p&gt;

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

/// &amp;lt;reference path="../support/index.d.ts" /&amp;gt;

describe('Cypress TS', () =&amp;gt; {
    it('should visit Google', () =&amp;gt; {
        cy.google();
    })
}) 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You can also add the &lt;code&gt;cypress run&lt;/code&gt; command to your scripts, this is a way to run cypress tests without open the default item.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;My goal was helping you to setup your cypress environment, you can search and learn about cypress and all its features later. There are a lot of things to see. &lt;/p&gt;

&lt;p&gt;Thanks for reading :)&lt;/p&gt;

</description>
      <category>cypress</category>
      <category>testing</category>
      <category>react</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
