<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Webpack &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/webpack/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 16:18:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>Webpack &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>Webpack: Managing Tree Shaking</title>
		<link>https://myshittycode.com/2019/07/09/webpack-managing-tree-shaking/</link>
					<comments>https://myshittycode.com/2019/07/09/webpack-managing-tree-shaking/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Wed, 10 Jul 2019 00:41:52 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Webpack]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=1108</guid>

					<description><![CDATA[<p>PROBLEM Sometimes, Webpack&#8217;s tree-shaking may accidentally eliminate imported code from import statements. For example, we may have a root JS file that imports a CSS file:- &#8230; and for some reason, the CSS file will never appear in the final bundle even if the Webpack config contains proper rules to handle CSS files. SOLUTION To [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2019/07/09/webpack-managing-tree-shaking/">Webpack: Managing Tree Shaking</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>Sometimes, Webpack&#8217;s tree-shaking may accidentally eliminate imported code from <strong>import</strong> statements.</p>



<p>For example, we may have a root JS file that imports a CSS file:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; highlight: [3]; title: ; notranslate">
import React from &#039;react&#039;;
import ReactDOM from &#039;react-dom&#039;;
import &#039;../css/index.css&#039;;

...
</pre></div>


<p>&#8230; and for some reason, the CSS file will never appear in the final bundle even if the Webpack config contains proper rules to handle CSS files.</p>



<h2 class="wp-block-heading">SOLUTION</h2>



<p>To prevent Webpack from removing any &#8220;unreferenced&#8221; code (ex: global CSS files, JS polyfills, etc), list these side effects under <strong>package.json</strong>, for example:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; highlight: [3,4,5]; title: ; notranslate">
{
  &quot;name&quot;: &quot;front-end-stack&quot;,
  &quot;sideEffects&quot;: &#x5B;
    &quot;*.css&quot;
  ]
}
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2019/07/09/webpack-managing-tree-shaking/">Webpack: Managing Tree Shaking</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2019/07/09/webpack-managing-tree-shaking/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1108</post-id>	</item>
		<item>
		<title>Webpack + ESLint: Automatically Fix ESLint Errors</title>
		<link>https://myshittycode.com/2018/04/02/webpack-eslint-automatically-fix-eslint-errors/</link>
					<comments>https://myshittycode.com/2018/04/02/webpack-eslint-automatically-fix-eslint-errors/#respond</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Mon, 02 Apr 2018 17:35:35 +0000</pubDate>
				<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[ESLint]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Webpack]]></category>
		<guid isPermaLink="false">http://myshittycode.com/?p=1079</guid>

					<description><![CDATA[<p>PROBLEM Given the following webpack.config.js&#8230; When running any Webpack command, ESLint may find violations and halt the entire process with the following error message:- SOLUTION Certain errors (ex: trailing commas, wrong indentation, extra semicolon) are easily fixable. There&#8217;s no need to halt the process and wait for developers to fix these obvious errors. To configure [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2018/04/02/webpack-eslint-automatically-fix-eslint-errors/">Webpack + ESLint: Automatically Fix ESLint Errors</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>Given the following <strong>webpack.config.js</strong>&#8230;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
module.exports = {
  ...
  module: {
    rules: &#x5B;
      {
        enforce: &#039;pre&#039;,
        test: /\.js?$/,
        loader: &#039;eslint-loader&#039;,
        exclude: /node_modules/,
      },
	  ...
    ],
  },
  ...
};
</pre></div>


<p>When running any Webpack command, ESLint may find violations and halt the entire process with the following error message:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
/path/to/front-end-stack/src/js/components/home/Home.js
  43:11  error  Expected indentation of 6 space characters but found 10  react/jsx-indent
  44:14  error  Expected indentation of 6 space characters but found 13  react/jsx-indent

x 2 problems (2 errors, 0 warnings)
  2 errors, 0 warnings potentially fixable with the `--fix` option.
</pre></div>


<h2 class="wp-block-heading">SOLUTION</h2>



<p>Certain errors (ex: trailing commas, wrong indentation, extra semicolon) are easily fixable.</p>



<p>There&#8217;s no need to halt the process and wait for developers to fix these obvious errors.</p>



<p>To configure ESLint to automatically fix these &#8220;soft&#8221; errors, add the following <strong>options</strong> block to the above rule:-</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; highlight: [10,11,12]; title: ; notranslate">
module.exports = {
  ...
  module: {
    rules: &#x5B;
      {
        enforce: &#039;pre&#039;,
        test: /\.js?$/,
        loader: &#039;eslint-loader&#039;,
        exclude: /node_modules/,
        options: {
          fix: true,
        },
      },
	  ...
    ],
  },
  ...
};
</pre></div>


<p>If you are using any VCS, remember to commit any file changes.</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2018/04/02/webpack-eslint-automatically-fix-eslint-errors/">Webpack + ESLint: Automatically Fix ESLint Errors</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2018/04/02/webpack-eslint-automatically-fix-eslint-errors/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1079</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching using Disk

Served from: myshittycode.com @ 2026-02-17 11:34:31 by W3 Total Cache
-->