<?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: Lokesh daiya</title>
    <description>The latest articles on DEV Community by Lokesh daiya (@lokeshdaiya).</description>
    <link>https://dev.to/lokeshdaiya</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%2F428240%2F94795222-6ce2-4a9e-8f35-395d2b216ad7.jpg</url>
      <title>DEV Community: Lokesh daiya</title>
      <link>https://dev.to/lokeshdaiya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lokeshdaiya"/>
    <language>en</language>
    <item>
      <title>How to use node_modules path or third party assets in angular files.</title>
      <dc:creator>Lokesh daiya</dc:creator>
      <pubDate>Sat, 20 Mar 2021 07:34:42 +0000</pubDate>
      <link>https://dev.to/lokeshdaiya/how-to-use-nodemodules-path-or-third-party-assets-in-angular-files-1jdj</link>
      <guid>https://dev.to/lokeshdaiya/how-to-use-nodemodules-path-or-third-party-assets-in-angular-files-1jdj</guid>
      <description>&lt;p&gt;Some times we need to use assets from node_modules in our angular project files.&lt;/p&gt;

&lt;p&gt;For example, you are using a third party package and you want to import css files from it in your &lt;code&gt;index.html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you try to import like this, it gives error:&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;link href="./node_modules/some_packge_name/assets/style.css"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So how to resolve this issue ??&lt;/p&gt;

&lt;p&gt;We can tell angular to copy required files in build.&lt;/p&gt;

&lt;p&gt;We can add &lt;code&gt;glob&lt;/code&gt; in &lt;em&gt;angular.json&lt;/em&gt; for &lt;code&gt;assets&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;build": {
          .....
           "assets": [
...
              {
                "glob": "**/*",
                "input": "./node_modules/some_packge_name/assets",
                "output": "./custom-assets"
              }
            ],
...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;input&lt;/code&gt;: Path of your &lt;code&gt;assets&lt;/code&gt; folder in &lt;em&gt;node_modules&lt;/em&gt;&lt;br&gt;
&lt;code&gt;output&lt;/code&gt;: Path you want to use in your application.&lt;/p&gt;

&lt;p&gt;now we can use it in our &lt;code&gt;index.html&lt;/code&gt; as below:&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;link href="./custom-asssets/style.css"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to use images from some package, you can use it as shown below:&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;img src="/custom-assets/some-img-file.png" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope you guys find these resources hopeful!&lt;/p&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>tooling</category>
      <category>fronted</category>
    </item>
  </channel>
</rss>
