Nordstrom and have a lot more in common than their hometown of Seattle.

Just like Amazon, Nordstrom has been spending big on technology, warehouses and expanding into new businesses. And like Amazon, sales have grown rapidly — while its profit shrinks.

The upscale department store’s overall revenue rose 9.8% to $3.12 billion for the quarter ending May 2. Comparable sales, which excludes newly opened or closed stores, rose 4.4% from the year-ago period, the strongest among the company’s peers.

Yet Nordstrom’s profit fell to $128 million from $140 million while its return on invested capital fell just over one percentage point to 12.2%.

So what gives?

Nordstrom has been pumping hundreds of millions of dollars into building up its digital sales, expanding into Canada and planning a beachhead in Manhattan. It’s doubling the size of its Rack outlet chain and acquired e-commerce sites like Trunk Club, as it looks to keep up with shoppers’ quickly changing behavior and avoid the doldrums afflicting many brick-and-mortar retailers.

“Our customer strategy is squarely focused on serving customers on their terms and delivering the high level of service they expect from us,” Blake Nordstrom, one of three siblings who are presidents at the retailer and scion of the company’s founding family, said on a conference call with investors.

It seems to be working with Nordstrom now getting 20% of sales from e-commerce. That’s well ahead of the 12% share of e-commerce at Macy’s M and comparable to Neiman Marcus, which has a natural advantage thanks to its legacy catalog business. Two years ago, Nordstrom only got 13% of sales online.

Nordstrom’s goal is to hit $20 billion in overall sales — bricks and mortar plus online — by 2020, 50% more than 2014 levels. To get there, the department store plans to spend $4.3 billion between now and 2019, or about 5% of sales.

The biggest chunk of that, $1.5 billion will be dedicated to technology and warehouses to speed up the delivery of online orders to better compete with Amazon, among others. For example, it is opening a new fulfillment center in Pennsylvania so that online orders can reach the East Coast more quickly.

Nordstrom is also spending big on things like updating its mobile shopping app and upgrading tools to better target customers with discount offers. It has added location-based features to it app and recently integrated its loyalty rewards program to make it easier for customers to redeem awards from mobile devices.

While Nordstrom’s full-service upscale department store will remain the centerpiece of the company’s business (by 2020, it would still represent 58% of sales, the company told Wall Street analysts on Thursday), it is clear growth will have to come from elsewhere. Its traditional department stores had comparable sales growth of a mere 0.5% in the first quarter. In contrast, sales rose 20%.

On the discount store front, online sales at Nordstrom Rack and Nordstrom’s flash sales site, rose 51% to $117 million even as comparable sales at physical Rack stores slipped a bit. launched only a year ago and the company has had to spend money to expand the assortment available on the site.

As for international expansion, Nordstrom recently opened its second Canadian store, in Ottawa. Long term, the retailer is planning six stores in Canada and thinks that market can eventually be a $1 billion business. It is also working on its first Manhattan department store, set to open in three years.

Wall Street has occasionally dinged Nordstrom for its big spending on new initiatives. But Thursday, after the earnings report, the company’s shares JWN rose despite the profit dip because management showed that the investments are paying off.

It’s a similar story at Amazon, although it has taken big spending to a new level by tolerating quarterly losses. That company has been building up its cloud computing business, adding perks to its Prime subscription shipping plan, opening warehouses, and testing online grocery delivery. The result has been an industry leader with sales that rose 15% last quarter, and a loss that investors sometimes grumble about but forgive AMZN .

There must be something in the water in Seattle.

For more about Amazon, watch this Fortune video: