<?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: Przemek Nowak</title>
    <description>The latest articles on DEV Community by Przemek Nowak (@fasosnql).</description>
    <link>https://dev.to/fasosnql</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%2F255571%2F95bcb199-a8da-44fa-852b-757f2b3e4b39.jpeg</url>
      <title>DEV Community: Przemek Nowak</title>
      <link>https://dev.to/fasosnql</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fasosnql"/>
    <language>en</language>
    <item>
      <title>ApolloClient - React useSuspenseQuery hook</title>
      <dc:creator>Przemek Nowak</dc:creator>
      <pubDate>Fri, 05 Jun 2020 14:30:52 +0000</pubDate>
      <link>https://dev.to/fasosnql/apolloclient-react-usesuspensequery-hook-1m8c</link>
      <guid>https://dev.to/fasosnql/apolloclient-react-usesuspensequery-hook-1m8c</guid>
      <description>&lt;p&gt;If some of you need hook to collaborate with React Suspense and Apollo Client - I've created one.&lt;/p&gt;

&lt;p&gt;According to discussion on &lt;a href="https://github.com/apollographql/apollo-feature-requests/issues/162"&gt;Apollo github&lt;/a&gt; - Apollo Client 3 won't have such a hook in first version. Yeah I know, Suspense is still in React experimental phase, but it looks like lot's of society started using it and it becomes an inseparable part of React. That's why I've created one and you can get it from this &lt;a href="https://www.npmjs.com/package/@brainly/use-suspense-query"&gt;npm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For now this hook is out of types, and still this code is not perfect, but it provide error handling and promise managing for &lt;code&gt;Apollo.query&lt;/code&gt;. We tested it at Brainly on one of our prototype project and works fine. &lt;br&gt;
Cheers!&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>apollo</category>
      <category>react</category>
      <category>suspense</category>
    </item>
    <item>
      <title>Angular - Custom Webpack Config to use SvgDocGen plugin</title>
      <dc:creator>Przemek Nowak</dc:creator>
      <pubDate>Fri, 21 Feb 2020 09:11:15 +0000</pubDate>
      <link>https://dev.to/fasosnql/angular-custom-webpack-config-to-use-svgdocgen-plugin-3j34</link>
      <guid>https://dev.to/fasosnql/angular-custom-webpack-config-to-use-svgdocgen-plugin-3j34</guid>
      <description>&lt;p&gt;Hello everyone, in last time I've posted &lt;a href="https://dev.to/fasosnql/svg-doc-generator-based-on-sprites-svg-1ao6"&gt;webpack plugin for generating demo and variables of your sprites.svg&lt;/a&gt; file. In this post I would like to show you how to add custom webpack configuration to your Angular project to use some plugins - in this article &lt;a href="https://github.com/Fasosnql/svg-doc-gen"&gt;SVG Doc Generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I will be working with angular project generated by &lt;code&gt;angular-cli&lt;/code&gt; so to go through it with me you can just generate simple app &lt;code&gt;ng new app-name&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When we have generated angular app we have to install some builders to build this app with additional webpack config. So let's install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;  npm &lt;span class="nb"&gt;install&lt;/span&gt; @angular-builders/custom-webpack @angular-builders/dev-server &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we have to update &lt;code&gt;angular.json&lt;/code&gt; to use installed builders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"architect"&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;"build"&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;"builder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@angular-builders/custom-webpack:browser"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"options"&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;"customWebpackConfig"&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;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./webpack.extends.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="nl"&gt;"replaceDuplicatePlugins"&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="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;as you can see name of my webpack config is &lt;code&gt;webpack.extends.js&lt;/code&gt; you can use whatever name you want.&lt;br&gt;
Dump below we have to change builder for &lt;code&gt;ng serve&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"serve"&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;"builder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@angular-builders/custom-webpack:dev-server"&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;In root directory according to &lt;code&gt;path&lt;/code&gt; which we added to angular.json we have to create &lt;code&gt;webpack.extends.js&lt;/code&gt; file. It is a file where we will be keeping our additional webpack configuration. For now let's just export empty object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Perfect, we've updated builders and added custom webpack config to Angular app. Everything is working so let's go to next step and let's add some custom plugin.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Custom Webpack Plugin
&lt;/h2&gt;

&lt;p&gt;As I mentioned above I'm gonna add &lt;a href="https://github.com/Fasosnql/svg-doc-gen"&gt;SVG Doc Generator&lt;/a&gt;. plugin. According to instruction we have to install it via npm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; svg-doc-gen
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Great, now we can configure plugin in our &lt;code&gt;webpack.extends.js&lt;/code&gt; file. But before it I will add my sprites.svg file to generate styles and demo html based on this. My SVG file looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;version=&lt;/span&gt;&lt;span class="s"&gt;"1.1"&lt;/span&gt;
  &lt;span class="na"&gt;xmlns=&lt;/span&gt;&lt;span class="s"&gt;"http://www.w3.org/2000/svg"&lt;/span&gt;
  &lt;span class="na"&gt;xmlns:xlink=&lt;/span&gt;&lt;span class="s"&gt;"http://www.w3.org/1999/xlink"&lt;/span&gt;
  &lt;span class="na"&gt;viewBox=&lt;/span&gt;&lt;span class="s"&gt;"0 0 24 24"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;defs&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
        svg.sprites {
        display: inline;
        }
        svg {
        display: none;
        }
        svg:target {
        display: inline;
        }

        svg[id^="primary-blue/"] use {
        fill: #047BC1;
        }

        svg[id^="primary-white/"] use {
        fill: #fefefe;
        }

        svg[id^="black/"] use {
        fill: #000000;
        }

        svg[id^="gray/"] use {
        fill: #AAAAAA;
        }

        svg[id^="green/"] use {
        fill: #197F86;
        }

        svg[id^="orange/"] use {
        fill: #C3561A;
        }

        svg[id^="red/"] use {
        fill: #B21F24;
        }

        svg[id^="secondary-blue/"] {
        fill: #002B49 !important;
        }

        svg[id^="white/"] {
        fill: #FFFFFF;
        }

      &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;g&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"def-icon1.svg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M0 0h24v24H0z"&lt;/span&gt; &lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/g&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;g&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"def-icon2.svg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41z"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M0 0h24v24H0V0z"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/g&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;g&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"def-icon3.svg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M0 0h24v24H0V0z"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/g&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;g&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"def-icon4.svg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M0 0h24v24H0z"&lt;/span&gt; &lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;"none"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d=&lt;/span&gt;&lt;span class="s"&gt;"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/g&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/defs&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--
        @SVGDoc
        name: Icon1
        variable: icon1
    --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"icon1.svg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="nt"&gt;&amp;lt;use&lt;/span&gt; &lt;span class="na"&gt;xlink:href=&lt;/span&gt;&lt;span class="s"&gt;"#def-icon1.svg"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--
        @SVGDoc
        name: Icon2
        variable: icon2
    --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"icon2.svg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;use&lt;/span&gt; &lt;span class="na"&gt;xlink:href=&lt;/span&gt;&lt;span class="s"&gt;"#def-icon2.svg"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--
        @SVGDoc
        name: Icon3
        variable: icon3
    --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"icon2.svg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;use&lt;/span&gt; &lt;span class="na"&gt;xlink:href=&lt;/span&gt;&lt;span class="s"&gt;"#def-icon2.svg"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!--
        @SVGDoc
        name: Icon4
        variable: icon4
    --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"icon4.svg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;use&lt;/span&gt; &lt;span class="na"&gt;xlink:href=&lt;/span&gt;&lt;span class="s"&gt;"#def-icon4.svg"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;

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



&lt;p&gt;As you see for every icon I've added &lt;code&gt;@SVGDocGen&lt;/code&gt; comment according to plugin documentation. Now we can configure plugin,&lt;br&gt;
Inside &lt;code&gt;webpack.extends.js&lt;/code&gt; we have to add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SVGDocGen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svg-doc-gen&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;SVGDocGen&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;svgDefsPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/assets/sprites.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;stylesConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/assets/styles/svg-vars.scss&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="na"&gt;styleLang&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;scss&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;svgPathInFile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;assets/sprites.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;htmlConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;outputPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/assets/svg-demo/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

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



&lt;p&gt;This is configuration which is taking &lt;code&gt;sprites.svg&lt;/code&gt; file from &lt;code&gt;assets&lt;/code&gt; folder and generating variables and demo html with icons to &lt;code&gt;assets&lt;/code&gt; folder.&lt;br&gt;
Now when you run &lt;code&gt;ng serve&lt;/code&gt; or &lt;code&gt;ng build&lt;/code&gt; according to path if you open &lt;code&gt;src/assets/svg-demo/index.html&lt;/code&gt; you should see that output:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fuN5kFCr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1zfzpnofe4t7te92q2zs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fuN5kFCr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1zfzpnofe4t7te92q2zs.png" alt="HTML output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And &lt;code&gt;src/assets/styles/svg-vars.scss&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nv"&gt;$icon1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"assets/sprites.svg#icon1.svg"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$icon2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"assets/sprites.svg#icon2.svg"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$icon3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"assets/sprites.svg#icon2.svg"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$icon4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"assets/sprites.svg#icon4.svg"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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



&lt;p&gt;Ok perfect, at the end we can just import our vars to &lt;code&gt;styles.scss&lt;/code&gt; to get usage of generated variables. I.e:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s2"&gt;"./assets/styles/svg-vars"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nc"&gt;.icon1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url($icon1)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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



&lt;p&gt;That's all from me, If you have some questions feel free to add comments below this article. If you have some problems with configuring let's download this &lt;a href="https://srv-file9.gofile.io/download/8APrqi/zip-svg.zip"&gt;zip&lt;/a&gt; package (this is working angular app generated for this article) and compare your code with code from this pack.&lt;/p&gt;

</description>
      <category>webpack</category>
      <category>javascript</category>
      <category>angular</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>SVG doc generator based on sprites.svg</title>
      <dc:creator>Przemek Nowak</dc:creator>
      <pubDate>Tue, 18 Feb 2020 17:48:17 +0000</pubDate>
      <link>https://dev.to/fasosnql/svg-doc-generator-based-on-sprites-svg-1ao6</link>
      <guid>https://dev.to/fasosnql/svg-doc-generator-based-on-sprites-svg-1ao6</guid>
      <description>&lt;p&gt;If some of you need a tool to generate SVG doc/demo of icons which are included in sprites.svg file I've created webpack plugin to achieve this. &lt;/p&gt;

&lt;p&gt;You can install it via NPM and take a look on source code in my &lt;a href="https://github.com/Fasosnql/svg-doc-gen"&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It generates for you demo html with svg icons and variables scss|less|css based on your svg sprites file.&lt;/p&gt;

&lt;p&gt;NPM link: &lt;a href="https://www.npmjs.com/package/svg-doc-gen"&gt;https://www.npmjs.com/package/svg-doc-gen&lt;/a&gt;&lt;/p&gt;

</description>
      <category>svg</category>
      <category>generator</category>
      <category>webpack</category>
      <category>javascript</category>
    </item>
    <item>
      <title>CSS Challenge #1</title>
      <dc:creator>Przemek Nowak</dc:creator>
      <pubDate>Wed, 05 Feb 2020 21:06:13 +0000</pubDate>
      <link>https://dev.to/fasosnql/css-challenge-1-3d8g</link>
      <guid>https://dev.to/fasosnql/css-challenge-1-3d8g</guid>
      <description>&lt;p&gt;Hello everyone, recently I've discovered that with gradient in CSS we can create amazing things, &lt;a href="https://leaverou.github.io/css3patterns/" rel="noopener noreferrer"&gt;here&lt;/a&gt; is a link what I've seen. For me it was incredible and I was thinking that its worth to go through it and learn this not readable (at the beginning) part of code. &lt;/p&gt;

&lt;p&gt;In general I have some habit about learning, when I'm discovering something I'm trying to create some exercise to summarise knowledge which I've just learned. Because of this I've created a exercise to draw only with gradients football pitch and this is what I achieved at the end:&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%2Fi%2F601bhhmdqffrlj1r2u18.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%2Fi%2F601bhhmdqffrlj1r2u18.png" alt="Results of CSS Gradient Challenge"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, I know there is no lots of details etc, but I realised that actually gradients in CSS are really schematic.&lt;/p&gt;

&lt;p&gt;So let's go and let's learn how easy gradients are. At the end of the article I shared link to repo with football pitch so you can go and take it and you will have local app to play with css gradients. But ok, no more talking, let's code!&lt;/p&gt;
&lt;h3&gt;
  
  
  First problem with gradients could be - how to create stripes with gradients?
&lt;/h3&gt;

&lt;p&gt;This is one of amazing and most know problem to solve with gradients, but thanks to it we can discover some new property which I didn't know. But let's start with some simple solution.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://jsfiddle.net/wbvsf216/1//embedded/result,css,html//dark" width="100%" height="600"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;What is going on there? Actually on this example you can understand basic concept of gradients. As you can see this is only a background, so still you can use every background properties. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;background: linear-gradient(90deg, blue 0, blue 1rem, red 1rem, red);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's divide this code in to smaller part. First property &lt;code&gt;90deg&lt;/code&gt; says about our angle of stripes. Then we are starting with drawing stripes. &lt;br&gt;
&lt;code&gt;blue 0, blue 1rem&lt;/code&gt; - its mean that our gradient starts from 0 from blue color and finising blue on 1rem. &lt;code&gt;red 1rem, red&lt;/code&gt; - Then red gradient start from 1rem and finish at the end.&lt;/p&gt;

&lt;p&gt;As you probably know, background has &lt;code&gt;repeat&lt;/code&gt; property and as a default it's working as &lt;code&gt;background-repeat: repeat&lt;/code&gt;. Thats why our gradient is repeating and filling all background.&lt;/p&gt;

&lt;p&gt;Second thing which we have to do is setting our background size, as default it is 100% 100%, so let's fit it to size of our gradient:&lt;br&gt;
&lt;code&gt;background-size: 2rem 100%;&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;I assume that on this basic example you've understood basic concept of gradients. So let's go to the next problem.&lt;/p&gt;
&lt;h3&gt;
  
  
  Second problem - how to create diagonal stripes?
&lt;/h3&gt;

&lt;p&gt;You could think that its actually easy, we have to just change angle of our linear-gradient property and thats all. Well, no especially, if you really understood above part then you can imagine that if you change your angle to i.e 45deg then you will have that effect:&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%2Fi%2Fat269p3eu7jygenizxb2.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%2Fi%2Fat269p3eu7jygenizxb2.png" alt="Wrong solution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and as you can see, at the bottom you have 2 gradient lines, 1rem of blue and 1rem of red, because our background-size is 2rem 100% thats why we have big horizontal line and only part of blue diagonal line... So the first thing what we could do is changing background-size into &lt;code&gt;background-size: 2rem 2rem;&lt;/code&gt;:&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%2Fi%2Fkdc3ut15cxzusyrihlac.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%2Fi%2Fkdc3ut15cxzusyrihlac.png" alt="Still wrong but netter"&gt;&lt;/a&gt;&lt;br&gt;
But it's not looks like diagonal stripes. So what the problem is?&lt;br&gt;
On above screenshot you can see that we have square with 2 parts 1rem of blue and 1rem of red - so this is what our code is saying. Now we have to change our square gradient into repeatable square which create stripes for us. Maybe you're remember that stripes background with image also required from us to create small square and repeat it - thanks to that solution we was able to receive stripes. The same things is with gradients, our square should look like:&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%2Fi%2F9rpf8nt18xw2juujrqpc.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%2Fi%2F9rpf8nt18xw2juujrqpc.png" alt="proper square"&gt;&lt;/a&gt;&lt;br&gt;
As you can see we have to create more gradients than 2 elements. First we have to create &lt;code&gt;25% of blue&lt;/code&gt;, then &lt;code&gt;25% to 50% of red&lt;/code&gt; then &lt;code&gt;50% to 75% of blue&lt;/code&gt; and at the end &lt;code&gt;75% to 100% of red&lt;/code&gt;. So let's code it!&lt;br&gt;
&lt;iframe src="https://jsfiddle.net/wbvsf216/4//embedded/result,css,html//dark" width="100%" height="600"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Amazing it's working, so what is the next problem? Actually let's stay in current one, what if we would like to change angle? As you can see our square is calculated to 45deg and from 0% to 100% we've provided gradient for it. When we change angle to 60deg then we have some ugly effect like not fitted image:&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%2Fi%2F5owwxca9l2a12ehzv75c.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%2Fi%2F5owwxca9l2a12ehzv75c.png" alt="Not fitted image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So what we can do, in general one of solution is to recalculate our gradient and change percentage values. But in fact it isn't flexible solution. CSS is coming with help to us, because there is one more gradient property... &lt;code&gt;linear-gradient&lt;/code&gt; and &lt;code&gt;radial-gradient&lt;/code&gt; has also properties &lt;code&gt;repeating-linear-gradient&lt;/code&gt;, &lt;code&gt;repeating-radial-gradient&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So instead of using &lt;code&gt;background-size: 2rem 2rem&lt;/code&gt; to keep our gradient in small square, we can define steps to repeat our gradient. In our case we could say that we would like to repeat our gradient by 1rem alternately blue/red.&lt;br&gt;
&lt;iframe src="https://jsfiddle.net/wbvsf216/6//embedded/result,css,html//dark" width="100%" height="600"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I think that explained to you how actually gradients works, and they are really schematic and simple in usage.&lt;/p&gt;

&lt;p&gt;If you would like to take this challenge and build football pitch fell free! If you're need some help add comment below article and I will try to answer you or just take a look on mine code in &lt;a href="https://github.com/Fasosnql/css-challenge-1" rel="noopener noreferrer"&gt;my repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cover Photo by Kobu Agency on Unsplash.&lt;/p&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>challenge</category>
    </item>
  </channel>
</rss>
