Amazon's (AMZN 1.49%) online marketplace crushed many brick-and-mortar retailers during the retail apocalypse, but Dollar Tree (DLTR -0.28%) survived that relentless assault and continued expanding.

It's tough for Amazon to compete against dollar stores, which often sell products for lower prices without extra shipping fees. Dollar Tree is the only American dollar store chain that still sells all of its products for $1. Family Dollar, which it bought in 2015, sells products at slightly higher prices.

But over the past 12 months, Amazon's stock rose roughly 40% against Dollar Tree's 20% decline. Let's see why Amazon stayed ahead of its dollar store rival, and whether or not that trend will continue.

E-commerce icons on a computer keyboard.

Image source: Getty Images.

How fast are Amazon and Dollar Tree growing?

Amazon generates most of its revenue from its online marketplaces, but most of its profits come from Amazon Web Services (AWS), the world's largest cloud infrastructure platform.

Last year, Amazon's revenue rose 20% as its earnings grew 14%. Its revenue grew 26% year over year in the first quarter, but its earnings declined 29% as it incurred roughly $600 million in pandemic-related expenses.

Tiny parcels on a laptop keyboard.

Image source: Getty Images.

It expects those costs to exceed $4 billion during the second quarter, which will likely result in a net loss even as its revenue rises 18% to 20%. Analysts expect its revenue to rise 24% this year as its earnings dip 17%.

Dollar Tree's revenue rose 3.5% last year as its enterprise same-store sales grew 1.8% -- including 2.3% growth at Dollar Tree and 1.4% growth at Family Dollar. However, its adjusted earnings declined 12% as higher tariffs on Chinese products reduced its gross margin.

In the first quarter, its revenue rose 8% as its enterprise same-store sales rose 7% -- as Family Dollar's 15.5% growth offset a 0.9% decline at Dollar Tree. Its adjusted EPS dipped nearly 4% as tariffs, Easter markdowns, higher payroll expenses, and an unfavorable merchandise mix reduced its margins.

Dollar Tree didn't provide any exact guidance in light of COVID-19, but it still plans to open 500 new stores this year -- compared to its prior plans for 550 new openings. Wall Street expects its revenue and earnings to both rise by about 6% this year.

The tailwinds and headwinds

Amazon and Dollar Tree are both naturally insulated from the COVID-19 crisis. Amazon's online orders are rising as more people stay at home, and AWS benefits from the growing usage of cloud and streaming services throughout the pandemic.

Dollar Tree kept all of its 15,300 namesake and Family Dollar locations open throughout the crisis, and they remained popular with cash-strapped shoppers stocking up on cheap essentials. Dollar Tree's stores are also generally located closer to lower-income neighborhoods than superstore chains like Walmart (WMT 1.02%) and Target (TGT -0.71%) -- which cuts unnecessary travel time and fuel costs throughout the crisis.

But both companies also face near-term headwinds. Amazon's online marketplace still faces competition from Walmart, Target, and other large retailers that can fulfill their online orders via brick-and-mortar stores. Its cloud business also faces intense competition from Microsoft's Azure.

Dollar Tree's Family Dollar -- which sells pricier products -- still faces stiff competition from Walmart, Amazon, and other discount retailers. However, store renovations, a new $1 Dollar Tree section, and alcoholic beverages reversed Family Dollar's decline over the past year. Dollar Tree and Family Dollar also don't face much direct competition from Dollar General (DG -1.36%), which focuses more heavily on rural areas instead of Dollar Tree's core urban and suburban markets.

The valuations and verdict

Amazon's stock trades at over 100 times forward earnings. That's a lofty valuation relative to its near-term earnings growth, but investors seem willing to pay a premium for the resilience of its e-commerce and cloud businesses throughout the crisis.

Dollar Tree trades at a more reasonable 19 times forward earnings, but its margins will likely be weighed down by tariffs. Its growth should remain stable over the next few years, but it lacks a secondary growth engine like AWS and Amazon Prime -- which recently surpassed 150 million subscribers worldwide.

Amazon and Dollar Tree are both sound long-term investments, but Amazon should attract more bulls as interest in Dollar Tree remains tepid. Therefore, Amazon should continue outperforming Dollar Tree throughout the rest of the year -- but investors should be mindful of its rising COVID-19 costs and frothy valuations.