Can you maintain or lose weight while pregnant?

I'm about 240 pounds and I've struggled with my weight for years. I really don't want to gain much at all during my pregnancy. Any advise or tips I can do??