It is a recommened practice to optimize your application for deploy. If you are working in an environment based on MSBuild or using Visual Studio in your day to day development and testing, then you may wish to automate this process. Below you will find some simple instructions explaining how to do this.
At the project root create your build config file, per the instructions from your chosen build tool.
Go to the project's properties and select
Build Events. In the post build event add the following (note that this example uses a hypothetical gulp build):
cd $(ProjectDir) gulp build
If you ony want to build when the Release configuration is selected, use the following:
if '$(Configuration)'=='Release' ( cd $(ProjectDir) gulp build )
Build your project. You should see the build output in the Output window.
In the solution explorer, select "Show All Files". Under the App folder, locate main-built.js. Right click and select 'Include in Project'.
Optionally, you can use the following code in your html page to automatically load the correct file (main.js vs. main-built.js).