<?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: Rafael Bastiansch</title>
    <description>The latest articles on DEV Community by Rafael Bastiansch (@rbastiansch).</description>
    <link>https://dev.to/rbastiansch</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%2F657310%2Fdb50aeea-7988-4dcb-88d5-e78af2f9645b.jpeg</url>
      <title>DEV Community: Rafael Bastiansch</title>
      <link>https://dev.to/rbastiansch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rbastiansch"/>
    <language>en</language>
    <item>
      <title>Library based on Vuetify, how we use and tips to avoid performance issues</title>
      <dc:creator>Rafael Bastiansch</dc:creator>
      <pubDate>Thu, 01 Jul 2021 00:52:28 +0000</pubDate>
      <link>https://dev.to/rbastiansch/library-based-on-vuetify-how-we-use-and-tips-to-avoid-performance-issues-2dh5</link>
      <guid>https://dev.to/rbastiansch/library-based-on-vuetify-how-we-use-and-tips-to-avoid-performance-issues-2dh5</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/rbastiansch/biblioteca-baseada-no-vuetify-como-nos-usamos-e-dicas-para-evitar-problemas-de-performance-4hdl"&gt;Versão em português&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;How to build a Design System inside a startup?&lt;br&gt;
I'm Rafael Bastiansch, Front End Tech Leader responsible for this architeture and I'm going to show how we build a design system at Logcomex and help you to build similar tool for your personal projects or job, I gonna show our stack today and why our library was build this way.&lt;br&gt;
To make you feel confortable with our business, I'll explain our projects at Logcomex:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the biggest one is a monolithic type, that sharing different purposes.&lt;/li&gt;
&lt;li&gt;new projects are created with &lt;a href="https://nuxtjs.org"&gt;Nuxt&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We wanted to create our new projects with same design but it was in separated repositories, so we had to reuse our basics components. The idea was to create a library that shares our pieces of code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First version with rollup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first version was build with rollup, but I have some problems just after we started. Using complex components from vuetify and separated scss, it started to generate some errors to compile the library. So I had to figure out what was happening and, after some POCs I tried Vue-CLI and it works like a charm. So due to lack of time we decided to keep using it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Version with vue-cli&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cli.vuejs.org"&gt;Vue-CLI&lt;/a&gt; have some good features built-in to use, build vue components to library is one of those, at that time as initial development and needed to build something fast was a good choice.&lt;/p&gt;

&lt;p&gt;To create a library with Vue-CLI, we init a project following the instructions and added some configurations to &lt;code&gt;vue.config.js&lt;/code&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 path = require('path');

module.exports = {
  configureWebpack: {
    resolve: {
      alias: {
        "~": path.resolve(__dirname)
      }
    },
  },
  css: {
    loaderOptions: {
      sass: {
        additionalData: `
          @import "@/assets/scss/_main.scss";
        `
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and add the script to &lt;code&gt;package.json&lt;/code&gt; to build our lib&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
"scripts": {
    "build": "vue-cli-service build --target lib src/index.js",
},
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The structure of our lib have &lt;code&gt;src/index.js&lt;/code&gt; file, it's where we imported all my components and prepare them to be imported when another project is using this package. You can check more about this here: &lt;a href="https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html#What-does-my-packaged-component-look-like"&gt;Vue cookbook&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export * from './components/inputs'
import * as inputs from './components/inputs'


const components = {
    ...inputs,
}

export function install (Vue) {
    for (const [name, component] of Object.entries(components)) {
        Vue.component(name, component)
    }
}

const plugin = {
  install
}

let GlobalVue = null;
if (typeof window !== "undefined") {
  GlobalVue = window.Vue;
} else if (typeof global !== "undefined") {
  // eslint-disable-next-line no-undef
  GlobalVue = global.Vue
}
if (GlobalVue) {
  GlobalVue.use(plugin);
}

export default plugin;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically, these are all the files that you will need to create/modify to start your own library with Vue-CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Current version and problems&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We're running our current version build using Vue-CLI for almost one year, it keeps the same way that was made and up to now it is good for us... but we have some improvements to do. We did this thinking in our current projects, so we have to keep them compatible.&lt;br&gt;
As we found some errors on consuming it we keep external libraries building within our package and that's a problem, the size of package increase as we add new features that requires external installations. Currently its size is 219KB zipped.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New version with some fixes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So right now I'm working to improve this, first of all I set all the third packages as external, this reduced the size of our old file to 58KB zipped, almost 4 times less than before. To achieve this you have to set libraries as externals in &lt;code&gt;vue.config.js&lt;/code&gt; inside configureWebpack key and it won't compile anymore.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
externals: [
  'dayjs',
  'moment',
  'ramda',
  'sortablejs'
],
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and migrate some dependencies to devDependencies(sorry, my mistake). It's the current changes I'm doing, after we use this new build to production we gonna see if it will be enough or if we will see more improvement to our lib.&lt;/p&gt;

&lt;p&gt;If you want to check it out and use or contribute, you will be more than welcomed.&lt;br&gt;
&lt;a href="https://github.com/comexio/design-system"&gt;Project github&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/rbastiansch/design-system/tree/build-improvement"&gt;New branch with improvement&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>npm</category>
    </item>
    <item>
      <title>Biblioteca baseada no Vuetify, como nós usamos e dicas para evitar problemas de performance</title>
      <dc:creator>Rafael Bastiansch</dc:creator>
      <pubDate>Thu, 01 Jul 2021 00:52:14 +0000</pubDate>
      <link>https://dev.to/rbastiansch/biblioteca-baseada-no-vuetify-como-nos-usamos-e-dicas-para-evitar-problemas-de-performance-4hdl</link>
      <guid>https://dev.to/rbastiansch/biblioteca-baseada-no-vuetify-como-nos-usamos-e-dicas-para-evitar-problemas-de-performance-4hdl</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/rbastiansch/library-based-on-vuetify-how-we-use-and-tips-to-avoid-performance-issues-2dh5"&gt;Version in English&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introdução&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Como construir um Design System dentro de uma startup?&lt;br&gt;
Sou Rafael Bastiansch, Tech Lead de Frontend responsável por esta arquitetura e vou mostrar como construímos um design system na Logcomex e ajudá-lo a construir uma ferramenta semelhante para seus projetos pessoais ou no trabalho, vou mostrar nossa stack hoje e porque nossa biblioteca foi construída desta forma.&lt;/p&gt;

&lt;p&gt;Para que você se sinta confortável com nosso negócio, vou explicar nossos projetos na Logcomex:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;o maior é um monolítico, que compartilha finalidades diferentes.&lt;/li&gt;
&lt;li&gt;novos projetos são criados com &lt;a href="https://nuxtjs.org"&gt;Nuxt&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Queríamos criar nossos novos projetos com o mesmo design, mas em repositórios separados, então tivemos que reutilizar nossos componentes básicos. A ideia foi criar uma biblioteca que compartilhasse nossos códigos.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nossa primeira versão com rollup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A primeira versão foi construída com rollup, mas tive alguns problemas logo no inicio. Usando componentes complexos de vuetify e scss separados, começou a gerar alguns erros para compilar a biblioteca. Então tive que descobrir o que estava acontecendo e, depois de algumas POCs, experimentei o Vue-CLI e funcionou perfeitamente. Por falta de tempo decidimos continuar a usá-lo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Versão com Vue-CLI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cli.vuejs.org"&gt;Vue-CLI&lt;/a&gt; tem alguns bons recursos embutidos para usar, gerar componentes Vue para biblioteca é um deles, naquela época como desenvolvimento inicial e necessário construir algo rápido foi uma boa escolha.&lt;/p&gt;

&lt;p&gt;Para criar uma biblioteca com Vue-CLI, iniciamos um projeto seguindo as instruções e adicionamos algumas configurações ao &lt;code&gt;vue.config.js&lt;/code&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 path = require('path');

module.exports = {
  configureWebpack: {
    resolve: {
      alias: {
        "~": path.resolve(__dirname)
      }
    },
  },
  css: {
    loaderOptions: {
      sass: {
        additionalData: `
          @import "@/assets/scss/_main.scss";
        `
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;e adicionar o script para o &lt;code&gt;package.json&lt;/code&gt; para buildar nossa lib&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
"scripts": {
    "build": "vue-cli-service build --target lib src/index.js",
},
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A estrutura de nossa lib possui o arquivo &lt;code&gt;src/index.js&lt;/code&gt;, é onde importamos todos os meus componentes e os preparamos para serem importados quando outro projeto estiver usando este pacote. Você pode verificar mais sobre isso aqui: &lt;a href="https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html#What-does-my-packaged-component-look-like"&gt;Vue cookbook&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export * from './components/inputs'
import * as inputs from './components/inputs'


const components = {
    ...inputs,
}

export function install (Vue) {
    for (const [name, component] of Object.entries(components)) {
        Vue.component(name, component)
    }
}

const plugin = {
  install
}

let GlobalVue = null;
if (typeof window !== "undefined") {
  GlobalVue = window.Vue;
} else if (typeof global !== "undefined") {
  // eslint-disable-next-line no-undef
  GlobalVue = global.Vue
}
if (GlobalVue) {
  GlobalVue.use(plugin);
}

export default plugin;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basicamente, esses são todos os arquivos que você precisará para criar/modificar sua própria biblioteca com Vue-CLI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Versão atual e problemas&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Estamos rodando nossa versão atual de build usando o Vue-CLI por quase um ano, continua da mesma forma que foi feita e até hoje é bom para nós... mas temos algumas melhorias a fazer. Fizemos isso pensando em nossos projetos atuais, então temos que mantê-los compatíveis.&lt;/p&gt;

&lt;p&gt;Como encontramos alguns erros ao consumir, mantemos as bibliotecas externas construídas em nosso pacote e isso é um problema, o tamanho do pacote aumenta à medida que adicionamos novos recursos que requerem instalações externas. Atualmente, o tamanho é 219KB compactado.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nova versão com algumas correções&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Agora estou trabalhando para melhorar isso, primeiro de tudo eu defini todos os pacotes de terceiros como externos, isso reduziu o tamanho do nosso arquivo antigo para 58KB compactado, quase 4 vezes menor do que antes. Para conseguir isso, você deve definir as bibliotecas como externals no &lt;code&gt;vue.config.js&lt;/code&gt; dentro da chave configureWebpack e ele não irá mais compilar junto.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
externals: [
  'dayjs',
  'moment',
  'ramda',
  'sortablejs'
],
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;e migrar algumas dependências para devDependencies(desculpe, erro meu). Essas são as alterações que estou fazendo, depois de usarmos esse novo build para produção, veremos se será suficiente ou se iremos procurar mais melhorias em nossa biblioteca.&lt;/p&gt;

&lt;p&gt;Se você quiser dar uma olhada e usar ou contribuir, será mais do que bem-vindo.&lt;br&gt;
&lt;a href="https://github.com/comexio/design-system"&gt;Projeto no github&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/rbastiansch/design-system/tree/build-improvement"&gt;Nova branch com as melhorias&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>npm</category>
    </item>
  </channel>
</rss>
