If you've properly setup the webpart then it should export with the code files as needed and you should be able to import it into staging and production. Make sure when importing to have the "import files" checked. Regarding custom tables, you can do the same as well. You can also export without data if you don't need it.