<?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>Forem: justinakingsley</title>
    <description>The latest articles on Forem by justinakingsley (@justinakingsley).</description>
    <link>https://forem.com/justinakingsley</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%2F1018980%2F263d1a3d-59cb-4099-b013-64a79e53b0f1.png</url>
      <title>Forem: justinakingsley</title>
      <link>https://forem.com/justinakingsley</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/justinakingsley"/>
    <language>en</language>
    <item>
      <title>Ecommerce with Stripe: A How to guide</title>
      <dc:creator>justinakingsley</dc:creator>
      <pubDate>Wed, 22 Feb 2023 16:47:00 +0000</pubDate>
      <link>https://forem.com/justinakingsley/ecommerce-with-stripe-a-how-to-guide-68g</link>
      <guid>https://forem.com/justinakingsley/ecommerce-with-stripe-a-how-to-guide-68g</guid>
      <description>&lt;p&gt;In today's digital age, it's crucial for businesses to have a seamless and secure payment system in place. Using an ecommerce platform that enables the integration of third-party payment providers like Stripe will simplify the payment process for customers and enhance the overall shopping experience, thereby increasing sales.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stripe.com/" rel="noopener noreferrer"&gt;Stripe&lt;/a&gt; is a widely-used payment gateway that offers a suite of payment APIs to help businesses accept payments online. Using a flexible ecommerce platform like &lt;a href="https://docs.medusajs.com/introduction" rel="noopener noreferrer"&gt;Medusa&lt;/a&gt; to set up your ecommerce site could be a game changer. &lt;/p&gt;

&lt;p&gt;Medusa provides the building blocks to create an ecommerce system with the necessary components, including processing payments and handling customer data with other advanced features that come with it. &lt;/p&gt;

&lt;p&gt;In this tutorial, you will explore the benefits of using Stripe and Medusa, and learn how to set up a complete ecommerce store with Stripe and Medusa.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Stripe?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://medusajs.com/blog/nextjs-ecommerce-storefront-comes-packed-with-ready-integrations-to-paypal-meilisearch-stripe-and-more/" rel="noopener noreferrer"&gt;Stripe&lt;/a&gt; is one of the biggest payment providers supporting thousands of businesses in the United States and globally. It provides a platform for businesses to process online payments. Stripe offers tools and services for businesses to accept customer payments, including a payment gateway, a payment processor, and a suite of developer-friendly APIs.&lt;/p&gt;

&lt;p&gt;Stripe supports a variety of payment methods, including credit cards, debit cards, Apple Pay, Google Pay, Microsoft Pay, Afterpay/Clearpay, Alipay, and ACH payments. Additionally, Stripe has fraud detection tools and can manage subscriptions and recurring payments. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnftidz1y2a18g2kk5ejj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnftidz1y2a18g2kk5ejj.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stripe is particularly popular among SMEs (Small and Medium-Sized Enterprises), developers, and online marketplaces. It is a good choice for ecommerce platforms looking to sell both locally and internationally. It provides tools for managing and analyzing transactions, as well as the ability to integrate with other software and services.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use Stripe?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Easy Integration: Stripe offers easy integration with websites and mobile apps, allowing businesses to quickly and easily start accepting payments online.&lt;/li&gt;
&lt;li&gt;Security: Stripe is compliant with industry security standards and regulations, providing customers with a secure and reliable payment experience.&lt;/li&gt;
&lt;li&gt;Developer-Friendly API: Stripe is known for its developer-friendly API and robust documentation, making it a popular choice among businesses and developers of all sizes and industries.&lt;/li&gt;
&lt;li&gt;Global Coverage: Stripe supports payments in over 135+ currencies and can be used in over 40 countries, allowing businesses to easily expand to new markets and accept payments from customers around the world.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Medusa?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.medusajs.com/introduction" rel="noopener noreferrer"&gt;Medusa&lt;/a&gt; is an open source, Node.ja-based, &lt;a href="https://medusajs.com/blog/composable-commerce/" rel="noopener noreferrer"&gt;composable commerce&lt;/a&gt; engine. Its APIs can be integrated with frontend tools to create a scalable ecommerce store.&lt;/p&gt;

&lt;p&gt;Medusa allows developers to build sophisticated commerce systems seamlessly. It’s great for developers who want full control over their development process. Medusa has three main components: the &lt;a href="https://medusajs.com/blog/headless-architecture/" rel="noopener noreferrer"&gt;headless&lt;/a&gt; server, &lt;a href="https://docs.medusajs.com/admin/quickstart" rel="noopener noreferrer"&gt;the admin panel&lt;/a&gt;, and the storefront for speed enhancement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7y62w4626trwdzk5882x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7y62w4626trwdzk5882x.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Medusa is a highly customizable platform that allows for seamless integration with various third-party services. This allows users to utilize the best solutions available in different areas, maximizing efficiency and optimizing their workflow.&lt;/p&gt;

&lt;p&gt;It has various features, including multiple payment options, a shopping cart, a &lt;a href="https://medusajs.com/blog/shopify-multi-currency-issue/" rel="noopener noreferrer"&gt;multi-currency feature&lt;/a&gt;, and third-party payment integration. Medusa commerce engine comes with a manual payment provider by default.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use Medusa?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Advanced Ecommerce Features: Medusa provides some advanced ecommerce features such as multi-currency, automated RMA flows, and sales channels.&lt;/li&gt;
&lt;li&gt;Developer-Friendly Features: Medusa has a pre-built open source codebase that developers clone. It has every feature of advanced ecommerce already built into it.&lt;/li&gt;
&lt;li&gt;Flexible Backend: Medusa uses &lt;a href="https://medusajs.com/blog/nodejs-ecommerce-backend/" rel="noopener noreferrer"&gt;Node.js backend&lt;/a&gt;; it is built in such a way that developers can easily study, understand, and write new code for what they intend to achieve.&lt;/li&gt;
&lt;li&gt;Third-Party Integration: Medusa supports integration with other services through plugins, which add new features and functionality to the platform. Some examples of such services are &lt;a href="https://docs.medusajs.com/add-plugins/segment" rel="noopener noreferrer"&gt;Segment&lt;/a&gt;, &lt;a href="https://docs.medusajs.com/add-plugins/contentful/customize-contentful" rel="noopener noreferrer"&gt;Contentful&lt;/a&gt;, &lt;a href="https://docs.medusajs.com/add-plugins/paypal" rel="noopener noreferrer"&gt;PayPal&lt;/a&gt;, &lt;a href="https://docs.medusajs.com/add-plugins/algolia" rel="noopener noreferrer"&gt;Algolia&lt;/a&gt;, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To follow through this tutorial effectively, ensure you have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt; version 14 or later&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://stripe.com/" rel="noopener noreferrer"&gt;Stripe&lt;/a&gt; Account with API keys ready&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to Set up Medusa Ecommerce with Stripe&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For this tutorial, you will use the Medusa commerce engine to build an ecommerce store; this will enable you to utilize all prebuilt features of Medusa for an easy development process. You’ll use the Medusa Server, Medusa Admin, and Medusa Storefront. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create a Medusa Server Project&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To create your new Medusa project, follow the steps below:&lt;/p&gt;

&lt;h3&gt;
  
  
  Install the Medusa CLI Tool
&lt;/h3&gt;

&lt;p&gt;Medusa CLI gets your computer ready to run the Medusa codebase locally. You can run this command below to install it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @medusajs/medusa-cli &lt;span class="nt"&gt;-g&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a New Medusa Server
&lt;/h3&gt;

&lt;p&gt;Creating a new Medusa project is simple; run the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;medusa new my-medusa-store &lt;span class="nt"&gt;--seed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;my-medusa-store&lt;/code&gt; is the name of the project folder, so you can edit it as you wish. If you have completed the above step successfully, switch to your new project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my-medusa-store
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, start your Medusa server with the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;medusa develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Medusa runs by default on port &lt;code&gt;9000&lt;/code&gt;. You can navigate to &lt;code&gt;localhost:9000/store/products/&lt;/code&gt; to see your store products.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Install Medusa Stripe Plugin
&lt;/h3&gt;

&lt;p&gt;The Stripe plugin is a package in Medusa that enables Stripe payment on your project. In the root of your Medusa project, run the following command to install the Stripe plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;medusa-payment-stripe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, in your &lt;code&gt;.env&lt;/code&gt; file, add the code snippet below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STRIPE_API_KEY=&amp;lt;STRIPE-API-KEY&amp;gt;
STRIPE_WEBHOOK_SECRET=&amp;lt;STRIPE-WEBHOOK-SECRET&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, replace &lt;code&gt;&amp;lt;STRIPE-API-KEY&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;STRIPE-WEBHOOK-SECRET&amp;gt;&lt;/code&gt;  with keys from your &lt;a href="https://dashboard.stripe.com/test/apikeys" rel="noopener noreferrer"&gt;Stripe dashboard&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Configure Stripe in Medusa Server
&lt;/h3&gt;

&lt;p&gt;Firstly, in &lt;code&gt;medusa-config.js&lt;/code&gt;, add the following at the end of the &lt;code&gt;plugins&lt;/code&gt; array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;plugins&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`medusa-payment-stripe`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRIPE_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;webhook_secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRIPE_WEBHOOK_SECRET&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;h3&gt;
  
  
  Create Medusa Admin
&lt;/h3&gt;

&lt;p&gt;Medusa Admin is a component of Medusa that allows merchants to handle all administrative functions which include product management, order management, customer management, discounts, currencies, regions, prices, settings, and more.&lt;/p&gt;

&lt;p&gt;The steps below will guide you in creating Medusa Admin:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Clone the Medusa Admin repository and switch the directory to the newly created folder:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/medusajs/admin medusa-admin
&lt;span class="nb"&gt;cd &lt;/span&gt;medusa-admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the command below to install all necessary dependencies:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Test it. Before you test the Medusa Admin, make sure your Medusa store server is running.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By default, Medusa Admin runs on port &lt;code&gt;7000&lt;/code&gt;; navigate to &lt;code&gt;localhost:7000&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8ojpg440ipzu87co986.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8ojpg440ipzu87co986.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Medusa has default admin login details: &lt;code&gt;admin@medusa-test.com&lt;/code&gt; as the email address and &lt;code&gt;supersecret&lt;/code&gt; as the password. The default admin credentials are added because you used the &lt;code&gt;--seed&lt;/code&gt; option while installing the Medusa server.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Enable Stripe in a Region
&lt;/h3&gt;

&lt;p&gt;Before you can use Stripe as a payment option during the checkout process of your storefront, you need to add it as a payment provider to every region in your store. Medusa Region is used to control the market in which your store operates. It supports multiple countries, payment options, and currencies.&lt;/p&gt;

&lt;p&gt;Follow the steps below to add Stripe in Medusa Region:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On your Medusa Admin dashboard, go to &lt;em&gt;Settings → Regions&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdnfq6z85d1r5g3yhj9j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffdnfq6z85d1r5g3yhj9j.png" alt=" " width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the region you want to edit from the &lt;em&gt;Regions&lt;/em&gt; section. This enables you to edit different information and data related to the region.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqmckyqguqt1wixe5lovj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqmckyqguqt1wixe5lovj.png" alt=" " width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the three-dot icon at the top right of the selected region. Select &lt;em&gt;Edit Region Details&lt;/em&gt; from the dropdown. This opens a new window where you can edit the region's details.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxc2w2u0g6cva77l12309.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxc2w2u0g6cva77l12309.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select Stripe as the only payment method from the &lt;em&gt;Payment Provider&lt;/em&gt; input field.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum5hsypfavc7za1fu7jo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum5hsypfavc7za1fu7jo.png" alt=" " width="800" height="593"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once done, click the &lt;em&gt;Save and close&lt;/em&gt; button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;You can repeat the steps above for other regions as well.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Creating Medusa Storefront&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Medusa has prebuilt storefronts in two frameworks: &lt;a href="https://docs.medusajs.com/starters/nextjs-medusa-starter" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; and &lt;a href="https://docs.medusajs.com/starters/gatsby-medusa-starter" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt;. This tutorial will focus on setting up a working storefront with Next.js and Stripe as its payment providers.&lt;/p&gt;

&lt;p&gt;To create a Medusa Storefront, follow the steps below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Create a new Next.js project using the &lt;a href="https://github.com/medusajs/nextjs-starter-medusa" rel="noopener noreferrer"&gt;Medusa starter template&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-next-app &lt;span class="nt"&gt;-e&lt;/span&gt; https://github.com/medusajs/nextjs-starter-medusa my-medusa-storefront
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Switch to the newly created directory, &lt;code&gt;my-medusa-storefront&lt;/code&gt;, and rename the template environment variable file to use environment variables in development:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my-medusa-storefront
&lt;span class="nb"&gt;mv&lt;/span&gt; .env.template .env.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Configure Stripe in Medusa Storefront
&lt;/h3&gt;

&lt;p&gt;In your &lt;code&gt;.env.local&lt;/code&gt; file (or the file you’re using for your environment variables), add the following variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NEXT_PUBLIC_STRIPE_KEY=&amp;lt;YOUR_PUBLISHABLE_KEY&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to replace &lt;code&gt;&amp;lt;YOUR_PUBLISHABLE_KEY&amp;gt;&lt;/code&gt; with your &lt;a href="https://dashboard.stripe.com/test/apikeys" rel="noopener noreferrer"&gt;Stripe Publishable Key&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test Stripe Payment
&lt;/h2&gt;

&lt;p&gt;Before you test Stripe payment in your storefront, ensure your Medusa server is running. Run the command below to start your storefront:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the above command, navigate to &lt;code&gt;localhost:8000&lt;/code&gt; to test your storefront. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzsybb0vlt56941fljj61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzsybb0vlt56941fljj61.png" alt=" " width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can try adding products to your shopping cart and checkout; you should be able to pay with Stripe.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03dh6jkhx8u634wn8qbb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03dh6jkhx8u634wn8qbb.png" alt=" " width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Capturing the Payment from the Admin
&lt;/h3&gt;

&lt;p&gt;When a payment is successfully made by a customer from your storefront, the payment is authorized but not captured. You’ll need to capture the payment from your admin panel.&lt;/p&gt;

&lt;p&gt;Follow the steps below to capture payments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the admin, go to &lt;em&gt;Orders ⇒ Select the particular order.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foykl4yl5vmpcu5b1woq3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foykl4yl5vmpcu5b1woq3.png" alt=" " width="800" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scroll down the page to Payment Card and click on &lt;em&gt;Capture Payment.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpyahl2int3ko6o6khfb8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpyahl2int3ko6o6khfb8.png" alt=" " width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once you capture the payment, the payment status will automatically turn to &lt;em&gt;Paid.&lt;/em&gt; Next, you can check your Stripe dashboard to view the payment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9aq4l1f5eh6pcvf0ckp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9aq4l1f5eh6pcvf0ckp.png" alt=" " width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This article explained what ecommerce is. It highlighted the features and benefits of Stripe and Medusa and showed a step-by-step guide to using Medusa ecommerce with Stripe. &lt;/p&gt;

&lt;p&gt;You can add the following integrations to your store:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.medusajs.com/add-plugins/segment" rel="noopener noreferrer"&gt;Segment&lt;/a&gt; plugin for advanced analytics and tracking,&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.medusajs.com/add-plugins/mailchimp" rel="noopener noreferrer"&gt;Mailchimp&lt;/a&gt; for adding a newsletter subscription to your ecommerce store, and&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.medusajs.com/add-plugins/contentful/" rel="noopener noreferrer"&gt;Contentful&lt;/a&gt; for rich CMS functionalities such as two-way sync for the content, localization, versioning, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can learn more from &lt;a href="https://docs.medusajs.com/introduction" rel="noopener noreferrer"&gt;Medusa Documentation&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Should you have any issues or questions related to Medusa, feel free to reach out to the Medusa team via &lt;a href="https://discord.gg/medusajs" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>How to use Webpack for Frontend asset Management and Optimization</title>
      <dc:creator>justinakingsley</dc:creator>
      <pubDate>Mon, 20 Feb 2023 12:54:14 +0000</pubDate>
      <link>https://forem.com/justinakingsley/how-to-use-webpack-for-frontend-asset-management-and-optimization-2e70</link>
      <guid>https://forem.com/justinakingsley/how-to-use-webpack-for-frontend-asset-management-and-optimization-2e70</guid>
      <description>&lt;p&gt;Webpack is a powerful asset management and build tool that has become a staple in modern frontend development. It allows developers to easily manage and optimize the various assets that make up a web application, including JavaScript files, CSS, images, and more. In this tutorial, we will cover the basics of using Webpack to improve the asset management and build process for your frontend projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Brief Overview of Webpack
&lt;/h2&gt;

&lt;p&gt;Webpack is a module bundler for JavaScript applications. It takes in your application's code and dependencies and outputs a single, optimized bundle that can be loaded into a web browser. By using Webpack, you can manage your assets in a more efficient and organized manner, and optimize your application for faster performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Explanation of the Benefits of Using Webpack
&lt;/h2&gt;

&lt;p&gt;There are several benefits to using Webpack in your frontend projects.&lt;/p&gt;

&lt;p&gt;First, it provides a unified and organized way to manage your assets, making it easier to maintain and update your code over time. &lt;/p&gt;

&lt;p&gt;Second, Webpack offers a wide range of optimization techniques that can significantly improve the performance of your application, such as minification, compression, code splitting, and more. &lt;/p&gt;

&lt;p&gt;Finally, Webpack is highly customizable and can be easily integrated with other tools and libraries, making it a versatile and essential tool for frontend development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;To get started with using Webpack, follow the steps below:&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Webpack
&lt;/h3&gt;

&lt;p&gt;To get started with Webpack, you first need to install it using npm. Simply run the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="nx"&gt;webpack&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Setting up a Basic Webpack Configuration
&lt;/h3&gt;

&lt;p&gt;Next, you will need to create a Webpack configuration file. This file tells Webpack how to process your assets and what outputs to generate. &lt;br&gt;
To create a basic configuration file, simply create a new file called &lt;code&gt;webpack.config.js&lt;/code&gt;in the root of your project and add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&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="nf"&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="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;entry&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/index.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bundle.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;path&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="nf"&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;dist&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding Your First File to the Webpack Build Process
&lt;/h3&gt;

&lt;p&gt;With your Webpack configuration file set up, you can now add your first file to the build process. In this example, we will add a simple &lt;br&gt;
JavaScript file called &lt;code&gt;index.js&lt;/code&gt;. To do this, create a new directory called &lt;code&gt;src&lt;/code&gt; in your project and create a new file inside that directory called &lt;code&gt;index.js&lt;/code&gt;. Add the following code to the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello, Webpack!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Managing Assets
&lt;/h2&gt;

&lt;p&gt;Aside from installing and configuring Webpack on your project, you need to learn how to manage Webpack also.&lt;/p&gt;

&lt;h3&gt;
  
  
  Loading Different File Types
&lt;/h3&gt;

&lt;p&gt;One of the great benefits of using Webpack is that it can handle a wide range of file types, including JavaScript, CSS, images, and more. To load different file types in Webpack, you will need to use loaders. Loaders are small modules that tell Webpack how to process specific file types.&lt;/p&gt;

&lt;p&gt;For example, to load CSS files, you can use the &lt;code&gt;style-loader&lt;/code&gt; and &lt;code&gt;css-loader&lt;/code&gt; modules. To install these loaders, run the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;loader&lt;/span&gt; &lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Loaders to Process Files Before They Are Included in the Build
&lt;/h3&gt;

&lt;p&gt;Once you have installed the necessary loaders, you need to configure Webpack to use them. This is done in the Webpack configuration file. In the following example, we will add support for loading CSS files in Webpack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&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;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="na"&gt;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;rules&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="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;css$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
          &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;style-loader&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;css-loader&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;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Configuring Webpack to Output Optimized Files
&lt;/h3&gt;

&lt;p&gt;By default, Webpack will output your assets as is, without any optimization. To take advantage of Webpack's optimization capabilities, you need to configure it to output optimized files. For example, to minify your JavaScript files, you can use the &lt;code&gt;terser-webpack-plugin&lt;/code&gt;module. To install this plugin, run the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="nx"&gt;terser&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;webpack&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;plugin&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Optimizing the Build Process
&lt;/h2&gt;

&lt;p&gt;Next, optimizing webpack build process is very important.&lt;/p&gt;

&lt;h3&gt;
  
  
  Minifying and Compressing Files
&lt;/h3&gt;

&lt;p&gt;To minify your JavaScript files, you can use the &lt;code&gt;terser-webpack-plugin&lt;/code&gt; module that you installed in the previous section. To use this plugin, add the following code to your Webpack configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TerserJSPlugin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&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;terser-webpack-plugin&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="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="na"&gt;optimization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;minimizer&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="nc"&gt;TerserJSPlugin&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;h3&gt;
  
  
  Splitting the Build into Multiple Chunks for Faster Loading
&lt;/h3&gt;

&lt;p&gt;Webpack also allows you to split your build into multiple chunks, which can be loaded in parallel for faster performance. This is especially useful for large applications with many assets. To split your build into chunks, you can use the &lt;code&gt;splitChunks&lt;/code&gt;configuration in Webpack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&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;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="na"&gt;optimization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;splitChunks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;all&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Source Maps to Debug Production Builds
&lt;/h3&gt;

&lt;p&gt;Finally, Webpack also supports generating source maps, which can be used to debug your application in production. To generate source maps, add the following code to your Webpack configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&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;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="na"&gt;devtool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;source-map&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced Features
&lt;/h2&gt;

&lt;p&gt;You can also look into Webpack advanced features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Integrating Webpack with Other Tools
&lt;/h3&gt;

&lt;p&gt;Webpack can also be integrated with other tools and libraries to enhance its functionality. For example, you can use Babel to transpile your JavaScript code, ESLint to enforce coding standards, and more. To integrate these tools with Webpack, you will need to use loaders and plugins.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Plugins to Extend Webpack's Functionality
&lt;/h3&gt;

&lt;p&gt;In addition to loaders, Webpack also supports plugins, which are modules that add additional functionality to Webpack. For example, you can use the &lt;code&gt;copy-webpack-plugin&lt;/code&gt; to copy files from your source directory to your output directory. To use this plugin, install it using npm, and then add the following code to your Webpack configuration &lt;br&gt;
file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CopyWebpackPlugin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&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;copy-webpack-plugin&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="c1"&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="nc"&gt;CopyWebpackPlugin&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;patterns&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="na"&gt;from&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&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;to&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&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;h3&gt;
  
  
  Hot Module Replacement (HMR)
&lt;/h3&gt;

&lt;p&gt;Hot Module Replacement (HMR) is a feature that allows you to update your application's code and see the changes in real-time, without having to refresh the page. HMR is especially useful during development, as it saves you time and makes the development process more efficient. To enable HMR in Webpack, add the following code to your Webpack configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&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;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="na"&gt;devServer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;hot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&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;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, you have covered the basics of Webpack and how to use it to build and optimize your web applications. From loading assets to splitting your build into multiple chunks, to integrating with other tools, Webpack provides a powerful and flexible platform for building modern web applications. Whether you are a beginner or an experienced developer, Webpack is a tool that you should have in your toolkit.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
  </channel>
</rss>
