<?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: Ramon Xavier</title>
    <description>The latest articles on DEV Community by Ramon Xavier (@ramonxm).</description>
    <link>https://dev.to/ramonxm</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%2F879477%2Ff63dc9b9-4967-42b2-9f81-27c39890dc4f.jpg</url>
      <title>DEV Community: Ramon Xavier</title>
      <link>https://dev.to/ramonxm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ramonxm"/>
    <language>en</language>
    <item>
      <title>Escolhendo entre Vite e CRA para seu projeto em React</title>
      <dc:creator>Ramon Xavier</dc:creator>
      <pubDate>Thu, 07 Mar 2024 01:50:02 +0000</pubDate>
      <link>https://dev.to/ramonxm/escolhendo-entre-vite-e-cra-para-seu-projeto-em-react-12cn</link>
      <guid>https://dev.to/ramonxm/escolhendo-entre-vite-e-cra-para-seu-projeto-em-react-12cn</guid>
      <description>&lt;p&gt;Desenvolver aplicações em React é uma prática comum, e para facilitar esse processo, duas ferramentas bastante populares são o Vite e o CRA (Create React App).&lt;/p&gt;

&lt;h2&gt;
  
  
  Estrutura de Projeto
&lt;/h2&gt;

&lt;p&gt;Ao escolher entre Vite e CRA, uma das diferenças notáveis é a estrutura de projeto. O CRA oferece uma estrutura pré-definida, com arquivos e pastas organizados de uma maneira específica. Em contrapartida, o Vite é mais flexível, permitindo que você escolha a estrutura de projeto que melhor atenda às suas necessidades.&lt;/p&gt;

&lt;h2&gt;
  
  
  Desempenho Superior com Vite
&lt;/h2&gt;

&lt;p&gt;O Vite se destaca pelo seu desempenho superior, principalmente devido à sua arquitetura baseada em módulos ES e ao uso eficiente da tecnologia de hot module replacement (HMR). Enquanto o CRA também é rápido, o Vite é conhecido por sua velocidade excepcional, garantindo uma experiência de desenvolvimento ágil e produtiva. O HMR no Vite, executado sobre o ESM nativo, resulta em atualizações mais rápidas, independentemente do tamanho do aplicativo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Modelo do Servidor CRA
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F42qx60tv8fq5w4qizzo7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F42qx60tv8fq5w4qizzo7.png" alt="CRA" width="670" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Modelo do Servidor Vite
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwnpos6vaglt7uus7lzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwnpos6vaglt7uus7lzu.png" alt="Vite" width="670" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Ferramenta de Construção Eficiente
&lt;/h2&gt;

&lt;p&gt;O Vite utiliza o esbuild como sua ferramenta de construção padrão, uma escolha que contribui para tempos de compilação extremamente rápidos e um desempenho de tempo de execução aprimorado. Essa eficiência no desenvolvimento é possível graças ao esbuild, uma ferramenta de construção de pacotes JavaScript rápida e eficiente.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuração Flexível
&lt;/h2&gt;

&lt;p&gt;A configuração é outra área em que o Vite e o CRA diferem. O CRA oferece uma configuração mais limitada, mas que é suficiente para a maioria dos projetos. Já o Vite proporciona uma configuração mais avançada, permitindo a personalização de diversas opções e extensões.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compatibilidade de Plug-ins Extensiva
&lt;/h2&gt;

&lt;p&gt;O Vite utiliza a interface de plug-ins do Rollup, o que significa que é compatível com a maioria dos plug-ins Rollup prontos para uso. Isso proporciona uma ampla gama de recursos para os desenvolvedores, permitindo a personalização e otimização de projetos.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tempo de Compilação Mais Rápido
&lt;/h2&gt;

&lt;p&gt;Para a criação de aplicativos para produção, o Vite utiliza o Rollup pré-configurado, conhecido por ser um empacotador mais eficiente que o webpack. Isso resulta em um tempo de compilação geralmente mais rápido que o do CRA, gerando uma saída menor em tamanho.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusão
&lt;/h2&gt;

&lt;p&gt;Com a mudança de recomendação do React para novos projetos, é crucial explorar opções além do CRA. Enquanto o Create Next App e o Remix são alternativas sugeridas pelo React, o Vite também se destaca como uma excelente opção para iniciar um projeto React. Sua velocidade, flexibilidade e compatibilidade de plug-ins oferecem uma experiência de desenvolvimento mais rápida e eficiente. Em última análise, a escolha da ferramenta dependerá das necessidades específicas do projeto e das preferências do desenvolvedor.&lt;/p&gt;

</description>
      <category>vite</category>
      <category>webdev</category>
      <category>react</category>
    </item>
    <item>
      <title>Publishing an NPM package to the Gitlab Package Registry</title>
      <dc:creator>Ramon Xavier</dc:creator>
      <pubDate>Tue, 05 Mar 2024 16:31:30 +0000</pubDate>
      <link>https://dev.to/ramonxm/publicando-um-pacote-npm-no-gitlab-package-registry-518a</link>
      <guid>https://dev.to/ramonxm/publicando-um-pacote-npm-no-gitlab-package-registry-518a</guid>
      <description>&lt;p&gt;In this post, we will explore how to publish a package on NPM using the GitLab Package Registry within a private repository. To get started, you will need to have the latest versions of Node and a package manager (npm or yarn) installed, as well as a GitLab account and a text editor of your choice, such as VSCode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Prerequisites: Node and (npm or yarn) in the latest versions.
GitLab account
VSCode or a text editor of your choice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Initializing the Project
&lt;/h2&gt;

&lt;p&gt;To manage a Monorepo and Yarn Workspaces, we will use Lerna. To start the project, follow the steps below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-project
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my-project
&lt;span class="nv"&gt;$ &lt;/span&gt;npx lerna init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add the necessary configurations to the lerna.json file, you should include the following code block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;In&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;./lerna.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"packages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"packages/*"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"npmClient"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"yarn"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"useWorkspaces"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"independent"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"publish"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"registry"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://gitlab.com/api/v4/projects/&amp;lt;your-project-id&amp;gt;/packages/npm/"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To capture the Project ID, go to your GitLab repository settings and check the value that appears in the URL. The Project ID is the number that appears after the slash in &lt;code&gt;https://gitlab.com/&amp;lt;your_user&amp;gt;/&amp;lt;your_repository&amp;gt;/edit&lt;/code&gt;, for example:&lt;br&gt;
&lt;code&gt;https://gitlab.com/my_user/my_repository/edit -&amp;gt; Project-ID: 123456&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To create a project within the repository, you can use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;packages
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside this repository, you can create an NPM project using the commands npm init, yarn init, or pnpm init.&lt;br&gt;
After creating your project, open the package.json file and add the following configurations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"publishConfig"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"@my-project:registry"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://gitlab.com/api/v4/projects/&amp;lt;your-project-id&amp;gt;/packages/npm/"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"sideEffects"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Returning to the GitLab Package Registry, after creating your project, let's see how to publish it to NPM within a private repository. To do this, return to the project root and create a file called .npmrc.&lt;br&gt;
This file is important because it contains the necessary configuration information to publish a package to NPM, including access credentials for the GitLab Package Registry. To create it, simply run the command &lt;code&gt;touch .npmrc&lt;/code&gt; in the terminal while in the root directory of your project.&lt;br&gt;
Next, add the following lines to the .npmrc file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// inside .npmrc
@my-project:registry&lt;span class="o"&gt;=&lt;/span&gt;https://gitlab.com/api/v4/packages/npm/
//gitlab.com/api/v4/packages/npm/:_authToken&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;authentication_token&amp;gt;
//gitlab.com/api/v4/projects/&amp;lt;project_id&amp;gt;/packages/npm/:&amp;lt;authentication_token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;project_id&amp;gt;&lt;/code&gt; with your GitLab project ID and &lt;code&gt;&amp;lt;authentication_token&amp;gt;&lt;/code&gt; with the access token you generated earlier. Remember that this token is sensitive and should not be shared publicly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Our AUTH TOKEN
&lt;/h2&gt;

&lt;p&gt;To begin, go to your GitLab repository settings by clicking on "Settings" at the bottom. To create an access token, go to your project settings in GitLab and access the "Access Tokens" section.&lt;/p&gt;

&lt;p&gt;When creating your access token, it is important to set the correct attributes to ensure the security of your project. Some of the information you should define includes:&lt;br&gt;
After creating your access token, you can return to your local project and publish it to the GitLab Package Registry using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;AUTH_TOKEN_GITLAB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;your_token_value&amp;gt; yarn build &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; lerna publish &lt;span class="nt"&gt;--yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything went well, by following the described steps, you will be able to see your project published in the Package Registry tab. This means that your library is available for use by other developers who have access to the GitLab repository. Remember that to ensure the security of your project and users, it is important to follow best security practices when configuring access permissions and sharing credentials. This way, you can contribute to a safer and more reliable development ecosystem.&lt;/p&gt;

&lt;p&gt;Now, to add your library to a project, you will need to create an .npmrc file in the project's root directory and add your library variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// inside .npmrc
@my-project:registry&lt;span class="o"&gt;=&lt;/span&gt;https://gitlab.com/api/v4/projects/&amp;lt;project-id&amp;gt;/packages/npm/
//gitlab.com/api/v4/projects/36997980/packages/npm/:_authToken&lt;span class="o"&gt;=&lt;/span&gt;AUTH_TOKEN_GITLAB
// finally, add your package to your project.
&lt;span class="nv"&gt;$ &lt;/span&gt;yarn add @my-project/my-lib or npm &lt;span class="nb"&gt;install&lt;/span&gt; @my-project/my-lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank you for reading, and I hope this was helpful! If you have any questions or suggestions, feel free to leave a comment below. We are always available to help improve your development experience. See you next time!&lt;/p&gt;

</description>
      <category>cicd</category>
      <category>gitlab</category>
      <category>runner</category>
      <category>lerna</category>
    </item>
  </channel>
</rss>
