<?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: Stephan Simonett</title>
    <description>The latest articles on DEV Community by Stephan Simonett (@wireless25).</description>
    <link>https://dev.to/wireless25</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%2F540261%2Ffcb518d6-0008-4cd1-a863-d059701f79c8.jpg</url>
      <title>DEV Community: Stephan Simonett</title>
      <link>https://dev.to/wireless25</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wireless25"/>
    <language>en</language>
    <item>
      <title>Why Webpack imports don't resolve in CI</title>
      <dc:creator>Stephan Simonett</dc:creator>
      <pubDate>Thu, 20 May 2021 10:53:48 +0000</pubDate>
      <link>https://dev.to/wireless25/why-do-my-webpack-imports-not-resolve-in-ci-3de1</link>
      <guid>https://dev.to/wireless25/why-do-my-webpack-imports-not-resolve-in-ci-3de1</guid>
      <description>&lt;p&gt;Your application is building locally perfectly fine, but in CI, imports are not resolving? I maybe have a hint for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem statement
&lt;/h2&gt;

&lt;p&gt;Let me lay out the issue I had a little bit more. We build web applications with VueJS. We use Webpack to bundle and optimize the JavaScript code. Imagine the following folder structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|-resources
  |-js
    |-Components
      |-TheNavigation
        |-Index.vue
        |-NavLink.vue
      |-TheFooter
        |-Index.vue
    |-Layouts
      |-Default.vue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the Webpack config, we set an alias to resolve the &lt;code&gt;@&lt;/code&gt; sign to &lt;code&gt;resources/js&lt;/code&gt; and omit the .vue file extension. Therefore when we import the navigation and the footer component into the default layout, this looks like the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;TheNavigation&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/Components/TheNavigation&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;TheFooter&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/Components/TheFooter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Consistent with the other component names, the &lt;code&gt;Index.vue&lt;/code&gt; also starts with a capital letter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build fails in CI
&lt;/h2&gt;

&lt;p&gt;We use Github Actions for continuous integration as well as for builds and deployments. We run all workflows on Linux systems.&lt;br&gt;
When we built a project with the situation above, it worked completely fine on our local machines. We use Macs.&lt;br&gt;
When we triggered the build on Github in a Linux container, it failed because it could not resolve the module imports from Webpack.&lt;/p&gt;

&lt;p&gt;The problem is that Linux has a case-sensitive system, other than Windows and macOS. Therefore, when you import, as seen above, the System searches for an &lt;code&gt;index.(whateverFileType)&lt;/code&gt;. On a Mac computer, the System finds the &lt;code&gt;Index.vue&lt;/code&gt; file and uses it. But as Linux is case sensitive in file names, it will not recognize &lt;code&gt;Index.vue&lt;/code&gt; as the same file as &lt;code&gt;index.vue&lt;/code&gt;. Therefore the module can not be resolved.&lt;/p&gt;

&lt;p&gt;It took me some time to figure this out, with a hint from &lt;a href="https://stackoverflow.com/questions/36365550/webpack-doesnt-resolve-properly-my-alias#answer-55923972"&gt;this answer on Stack Overflow&lt;/a&gt; I realized that case-sensitivity could be the problem. After changing all &lt;code&gt;Index.vue&lt;/code&gt; files to &lt;code&gt;index.vue&lt;/code&gt;, the build ran on the Linux machine.&lt;/p&gt;

&lt;p&gt;Of course, it would be possible to add the whole path, inclusive filename, and extension, but in my opinion, this looks way less clean and is more code to write. &lt;/p&gt;

&lt;p&gt;I hope this helps at least one developer, as it was a big pain in the ass to figure out. The solution is not what I was looking for. Rather I was debugging the Webpack config instead, which obviously was utterly useless.&lt;/p&gt;

</description>
      <category>webpack</category>
      <category>linux</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
