<?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: Rahimuddin</title>
    <description>The latest articles on DEV Community by Rahimuddin (@mdrahiem).</description>
    <link>https://dev.to/mdrahiem</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%2F178375%2F261c740f-f2cd-43ea-b306-3a310b604292.jpg</url>
      <title>DEV Community: Rahimuddin</title>
      <link>https://dev.to/mdrahiem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mdrahiem"/>
    <language>en</language>
    <item>
      <title>Emporter - a saviour for exposing localhost to web</title>
      <dc:creator>Rahimuddin</dc:creator>
      <pubDate>Fri, 29 Apr 2022 13:37:32 +0000</pubDate>
      <link>https://dev.to/mdrahiem/emporter-a-saviour-for-exposing-localhost-to-web-4321</link>
      <guid>https://dev.to/mdrahiem/emporter-a-saviour-for-exposing-localhost-to-web-4321</guid>
      <description>&lt;p&gt;&lt;strong&gt;TLDR:&lt;/strong&gt; Emporter is a simple tool using which you can expose your localhost to web in realtime. It's free and no complex configuration.&lt;/p&gt;

&lt;p&gt;Jump to "How to use"&lt;/p&gt;

&lt;p&gt;So the requirement was I wanted to work on the responsiveness of a web application but I wanted for a specific device and a real device because I wanted to test the "Reachability" mode on iOS.&lt;/p&gt;

&lt;p&gt;I tried multiple solutions from &lt;a href="https://stackoverflow.com/"&gt;stackoverflow&lt;/a&gt; and few &lt;a href="https://www.youtube.com/"&gt;youtube&lt;/a&gt; videos as well. I will give the examples because I know when someone visits this article they might already have the knowledge of other tools. If not they will have with this info :)&lt;/p&gt;

&lt;p&gt;The below are the solutions which I have tried.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/3132105/how-do-you-access-a-website-running-on-localhost-from-iphone-browser"&gt;access localhost from mac to iPhone using network/sharing settings and connecting cable&lt;/a&gt;&lt;br&gt;
Initially I thought it's a simple solution but may be because the laptop was provided by my organisation (network settings). I am not very sure though. Ideally it should have been worked with a simple solution like &lt;a href="https://stackoverflow.com/a/9304094"&gt;this&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://ngrok.com/"&gt;ngrok&lt;/a&gt; - I was unable to install it because it was a third party tool and my mac doesn't allow me.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://apps.apple.com/us/app/port2/id1522650072?mt=12"&gt;Port2 app for mac&lt;/a&gt; - It was not free and the only one session it provided didn't work for me. It shows &lt;code&gt;undefined&lt;/code&gt; url and simply didn't work&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then I found &lt;a href="https://apps.apple.com/nl/app/emporter/id1406832001?mt=12"&gt;this&lt;/a&gt; mac app from app store and it worked like a charm.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Once you install this app, you will see the icon on the top menu bar. Once you click on that you will see there are no connections.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q6dBPSYs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4h4y52e75guky4ngylb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q6dBPSYs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4h4y52e75guky4ngylb.png" alt="Emporter step1" width="552" height="764"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on the '+' icon&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0s552zE3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i7sadv35pcuutu8nmxai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0s552zE3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i7sadv35pcuutu8nmxai.png" alt="Emporter step2" width="552" height="764"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--upBDxm2H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzhyu1vlo8f0krv8nevq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--upBDxm2H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzhyu1vlo8f0krv8nevq.png" alt="Emporter step3" width="552" height="764"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--if996TVm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9ldt8dz0yf3w2nxw3zo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--if996TVm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9ldt8dz0yf3w2nxw3zo.png" alt="Emporter step4" width="552" height="764"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because it's a premium version, it will generate a random url instead of the given name. You can click on the connection and "Reveal in browser". It's live and it's realtime.&lt;/p&gt;

&lt;p&gt;If at all this article is helpful, do give it a 'Heart'. Always appreciate it. :)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>macos</category>
      <category>mobile</category>
      <category>responsive</category>
    </item>
    <item>
      <title>Minimize the below code</title>
      <dc:creator>Rahimuddin</dc:creator>
      <pubDate>Fri, 15 Jan 2021 10:46:55 +0000</pubDate>
      <link>https://dev.to/mdrahiem/minimize-the-below-code-k0d</link>
      <guid>https://dev.to/mdrahiem/minimize-the-below-code-k0d</guid>
      <description>&lt;p&gt;How to handle this with less code?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;if (customerIdNumber === '' || customerIdNumber === 'null' || customerIdNumber === null || isNaN(customerIdNumber)) {&lt;br&gt;
alert('success');&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I'm already using &lt;code&gt;lodash&lt;/code&gt; library in the project. So I've tried to use this.&lt;br&gt;
&lt;code&gt;_.isEmpty(customerIdNumber)&lt;/code&gt; but this doesn't work for all above.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>javascript</category>
      <category>codequality</category>
      <category>react</category>
    </item>
    <item>
      <title>Add .less/.scss global styles in storybook</title>
      <dc:creator>Rahimuddin</dc:creator>
      <pubDate>Tue, 22 Sep 2020 12:54:41 +0000</pubDate>
      <link>https://dev.to/mdrahiem/add-less-scss-global-styles-in-storybook-1k50</link>
      <guid>https://dev.to/mdrahiem/add-less-scss-global-styles-in-storybook-1k50</guid>
      <description>&lt;p&gt;I am trying to integrate storybook tool with my react app. My app is using &lt;code&gt;.less&lt;/code&gt; styles and I've a single file in which all the styles are written (though I am not a big fan of this practice :))&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It works for v6 but I am not sure about lower versions. You guys can give it a try.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After successful installation of storybook, we have two files (&lt;code&gt;main.js&lt;/code&gt; and &lt;code&gt;preview.js&lt;/code&gt;) in &lt;code&gt;.storybook&lt;/code&gt; folder. As we know &lt;code&gt;main.js&lt;/code&gt; is the config file for storybook and &lt;code&gt;preview.js&lt;/code&gt; is the config file for our stories.&lt;/p&gt;

&lt;p&gt;The idea is here to include Webpack configuration in storybook.&lt;br&gt;
Question: How can we do it? &lt;br&gt;
Ans:  Using &lt;code&gt;main.js&lt;/code&gt; file&lt;/p&gt;

&lt;h2&gt;
  
  
  Step1:
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
  "stories": [
    "../src/**/*.stories.mdx",
    "../src/**/*.stories.@(js|jsx|ts|tsx)"
  ],
  "addons": [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/preset-create-react-app",
    '@storybook/preset-scss'
  ],
  webpackFinal: async (config, { configType }) =&amp;gt; {
    config.module.rules.push({
      // this is for both less and scss
      test: /.*\.(?:le|c|sc)ss$/,
      loaders: [
        'style-loader',
        'css-loader',
        'less-loader', // if scss then add 'sass-loader'
      ]
    });
    config.plugins.push(new MiniCssExtractPlugin({
      filename: '[name]-[contenthash].css',
      chunkFilename: '[id]-[contenthash].css',
    }));
    return config;
  },
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;config&lt;/code&gt; is the object of existing storybook's webpack configuration. We are pushing the rules and plugins to this &lt;code&gt;config&lt;/code&gt; object.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step2:
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;preview.js&lt;/code&gt; file include the below line&lt;/p&gt;

&lt;p&gt;for &lt;code&gt;less&lt;/code&gt;:&lt;br&gt;
&lt;code&gt;import '!style-loader!css-loader!less-loader!../YOUR_LESS_FILE.less';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;for &lt;code&gt;scss&lt;/code&gt;:&lt;br&gt;
&lt;code&gt;import '!style-loader!css-loader!sass-loader!../YOUR_LESS_FILE.scss';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's it. Now you can run storybook and preview the changes :)&lt;/p&gt;

&lt;p&gt;PS: I would like to thank Bastien for this reply on github thread.&lt;br&gt;
&lt;a href="https://github.com/storybookjs/storybook/issues/6364#issuecomment-485651328"&gt;https://github.com/storybookjs/storybook/issues/6364#issuecomment-485651328&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also I would like to thank @codevolution youtube channel for his awesome tutorials on storybook.&lt;br&gt;
&lt;a href="https://www.youtube.com/playlist?list=PLC3y8-rFHvwhC-j3x3t9la8-GQJGViDQk"&gt;https://www.youtube.com/playlist?list=PLC3y8-rFHvwhC-j3x3t9la8-GQJGViDQk&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>storybook</category>
      <category>reactnative</category>
      <category>webpack</category>
    </item>
    <item>
      <title>Decrease react app bundle size using webpack-merge</title>
      <dc:creator>Rahimuddin</dc:creator>
      <pubDate>Thu, 23 Jul 2020 11:59:56 +0000</pubDate>
      <link>https://dev.to/mdrahiem/decrease-react-app-bundle-size-using-webpack-merge-11jh</link>
      <guid>https://dev.to/mdrahiem/decrease-react-app-bundle-size-using-webpack-merge-11jh</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;First of all I am very new to writing articles. Please bear with me.&lt;/p&gt;

&lt;p&gt;While developing a react app we generally have a local host server, hot-reloading and &lt;a href="https://webpack.js.org/configuration/devtool/" rel="noopener noreferrer"&gt;strong source mapping&lt;/a&gt; which don't need in production for obvious reasons. So it doesn't make sense to have these tools unnecessarily which increases the bundle size.&lt;/p&gt;

&lt;p&gt;To minimize bundle size by having these tools only in development we can make use of a plugin called &lt;a href="https://github.com/survivejs/webpack-merge" rel="noopener noreferrer"&gt;webpack-merge&lt;/a&gt;. So, to achieve this we are going to follow the below steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step1:
&lt;/h2&gt;

&lt;p&gt;Install &lt;code&gt;webpack-merge&lt;/code&gt; using &lt;code&gt;yarn add --dev webpack-merge&lt;/code&gt; or &lt;code&gt;npm install --save-dev webpack-merge&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step2:
&lt;/h2&gt;

&lt;p&gt;split the existing webpack.config.js to three files.&lt;/p&gt;

&lt;p&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%2Fmuw2wmgp9m6402mfi5el.jpg" 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%2Fmuw2wmgp9m6402mfi5el.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;webpack.common.js&lt;/strong&gt; It contains the common code which we use for development and production both&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');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const localConfig = require('./src/common/localConfig');

module.exports = {
  entry: {
    index: './src/index.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'src'),
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env', '@babel/preset-react'],
            plugins: [
              '@babel/plugin-transform-runtime',
              '@babel/plugin-proposal-class-properties'
            ]
          }
        }
      },{
        test: /logo.svg$/,
        loader: 'svg-url-loader'
      }, {
        test: /abcd-.*\.(?:le|c)ss$/,
        loaders: [
          MiniCssExtractPlugin.loader,
          'css-loader',
          'less-loader',
        ]
      }
    ],
  },
  plugins: [
    new CleanWebpackPlugin({ cleanStaleWebpackAssets: false }),
    new HtmlWebpackPlugin({
      template: "./src/index.ejs",
      inject: true,
      filename: "./index.html",
      templateParameters: {
        'localConfig': localConfig
      }
    }),
    new MiniCssExtractPlugin({
      filename: '[name]-[contenthash].css',
      chunkFilename: '[id]-[contenthash].css',
    }),
    new CopyPlugin(
      [
        { from: 'public', to: '' },
      ],
    ),
  ],
  output: {
    filename: '[name].[hash].bundle.js',
    path: path.resolve(__dirname, 'dist'),
  },
  optimization: {
    splitChunks: {
      chunks: 'all',
    },
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(the above is only sample code. It doesn't to match with yours)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;webpack.dev.js&lt;/strong&gt; It contains the development code which includes local server, hot reloading etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { merge } = require('webpack-merge');
const common = require('./webpack.common');

module.exports = merge(common, {
  mode: 'development',
  devtool: 'inline-source-map',
  devServer: {
    port: 3003,
    https: true,
    contentBase: './dist',
    hot: true,
    allowedHosts: [
      'local.dev.abcdefg.net'
    ],
    public: 'https://local.dev.abcdefg.net:3003/',
    publicPath: '/',
    open: {
      // This doesn't actually work
      app: ['firefox']
    }
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;webpack.prod.js&lt;/strong&gt; It contains the production related code which doesn't include much (specifically)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { merge } = require('webpack-merge');
const common = require('./webpack.common');

module.exports = merge(common, {
  mode: 'production',
  devtool: 'source-map'
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step3:
&lt;/h2&gt;

&lt;p&gt;run &lt;code&gt;npm run build&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now you can compare the build size before and after. :)&lt;/p&gt;

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