Trex Company (TREX 1.25%), best known for its decking and related products, is a hit with both homeowners and environmentalists. The company's core product is made from 95% recycled materials -- primarily polyethylene film that's one of the harder plastics to recycle -- and lasts a lot longer than a wood deck. Moreover, it doesn't require the annual cleaning, or chemical bath of treating and staining that wood decks also need. 

Over the past decade, Trex has been a fantastic investment, too. Since the beginning of 2010, sales have increased by 165% and the stock price is up more than 1,700% as the company transitioned from a money loser coming out of the Great Recession to record profits. As things stand today, Trex looks like a company that's firing on all cylinders. After a speed bump in early 2019 as the company faced demand that it couldn't meet, it's back to double-digit growth, with plans to more than double its manufacturing capacity by 2021. Investors are optimistic, too. Trex's stock is very close to its all-time high. 

Foot stepping on a banana peel.

It may seem like a mistake to buy Trex with a recession on the horizon. But long-term investors shouldn't hold off. Image source: Getty Images.

But is all that optimism a poorly placed bet on a consumer discretionary stock, a category that doesn't do well during a weak economy? After all, there are indications that recession could be just around the corner. Let's take a closer look a the risks and how investors should approach investing in Trex. 

From on the ropes to industry leader

Over the past decade, management has taken what was a financially troubled company with low-quality products, and turned it into a highly profitable industry leader. Trex has by far the biggest reach of any alt-wood decking maker. Its products are available from the biggest big-box home-improvement retailers as well as some of the largest lumber and building materials distributors in the U.S., and the company has developed extensive ties with building contractors, many of whom lead with Trex when a client hires them for a deck project. 

This two-pronged approach to distribution, along with Trex's investments in marketing across traditional media, trade publications, and social media, has helped Trex become the leader in market share and by far the most recognized brand in alt-wood decking. 

Since 2014, the company has grown sales from less than $400 million to over $720 million, which works out to an incredible 15% compound annual growth rate. Moreover, it's been able to turn that double-digit decking sales growth into even bigger profit growth. Over that same period, Trex has grown earnings per share 360%, a combination of both improvements in its manufacturing and the benefits of operating leverage as its manufacturing scale gets larger. 

TREX EPS Diluted (TTM) Chart

TREX EPS diluted (TTM). Data by YCharts.

Planning for even more growth ahead

Earlier this year, Trex took a bit of a beating when management adjusted its expectations for 2019 lower. The interesting thing about the guidance reduction was that it was a product of planned spending to significantly increase Trex's production capacity. In other words, Trex management wasn't expecting earnings to fall because of weak consumer demand. To the contrary, the company couldn't meet the demand it was already seeing, and was going to spend significantly more to build additional manufacturing capacity this year, and would also face higher operating costs to launch new products and new production lines. 

That's what we call a high-class problem, and volumes continue to grow. Trex must add new capacity in order to continue to meet the current pace of demand. 

But is Trex building new lines at a bad time? 

There's an argument that Trex's investments, and the operating costs that will come along with that new capacity, could be coming on line at the worst possible time, if the U.S. were to fall into a recession. Decking projects are very expensive and fall far across the line between necessary and into discretionary. 

If Trex brings that new capacity on line and then we see a recession, the company would likely not be able to keep growing its margins the way it has over the past decade.

TREX Operating Margin (TTM) Chart

TREX operating margin (TTM). Data by YCharts.

As a matter of fact, we would almost certainly see those margins -- and the profits Trex derives from them -- fall sharply if demand for decking were to soften. There's even the risk that some customers who would buy Trex in more certain economic times might even choose wood, simply because the up-front investment is cheaper. 

How bad could it be? Here's how Trex held up during the last recession:

TREX Operating Margin (TTM) Chart

TREX operating margin (TTM). Data by YCharts.

There's not beating around the bush here. Trex absolutely got hammered during the Great Recession. Sales fell, and its high operating costs led to massive losses that continued even after the economy returned to growth. 

But Trex is a different company today 

Yes, Trex struggled mightily coming out of the Great Recession. And I think it's a lock that another recession would also affect sales and profits, and could even result in the company losing money for a few quarters. But it's also a step too far to draw a line between how the company performed in the Great Recession and how it would likely do in the next economic downturn.

To start, the company's financial profile has changed substantially.

TREX Cash and Equivalents (Quarterly) Chart

TREX cash and equivalents (quarterly). Data by YCharts.

Things got so bad, Trex was nearly bankrupted during the Great Recession. Today, it carries no long-term debt, though it does use a credit line for seasonal liquidity to fund its inventory build prior to distributors taking on inventory during deck-building season in the spring. The company also carries a significant cash cushion, a product of how much more cash flows its business generates today than it ever has before. 

The result is a company that would be able to weather a recession just fine. Even if business weakened for a period of time, Trex's strong balance sheet will likely prove a huge safety net during the next recession. 

So what should investors do?

My expectations are that investors who pay today's price for Trex stock and hold it for the next 10 years will be very happy with their returns. 

Sure, there's the very real risk that a recession will happen soon. And I think it's likely that when it does happen, Trex's sales and profits could fall, and its stock price will drop when investors flee in fear. But instead of using that concern as a reason to hold off, investors would likely do better to buy Trex today and look at a future market sell-off during a recession as an opportunity to buy more. 

The reality is, nobody knows when the next recession will happen or how long it will last when it does. Instead of letting worries over something that's inevitable and unpredictable keep you from investing in a great company like Trex, have a plan to invest through the market's ups and downs and to act opportunistically when it gives you a chance to buy more at bargain prices.