You can build your application for production using
ng build --configuration=production
Then you can check you angular.json
for the key outputPath
where it normally has the value dist
but could be different as well.
"build": {
"options": {
"outputPath": "dist"
With dist
as value the outputed files from the build would be placed under the folder /dist
When built your angular project will consist only from static files Html, Javascript, Css and images or other assets. Because of that, what you need is just a web server that can serve static files to the client. Simple as that. Can be nginx, tomcat whatever can serve those static files to a client. This is also stated in the angular doc
Because these files are static, you can host them on any web server
capable of serving files
Your built project under outputPath will already contain an index.html
which will automatically have all necessary imports so when index.html
is delivered to the client, the browser will also fetch all other necessary files. Necessary info is already contained in index.html
.
Your second part of the question
do I minify them using gulp
The official way
angular.json
will contain specific configurations for each environment and one of those will be optimization
optimization
can be a boolean (true, false)
"configurations": {
"production": {
"optimization": true --> will mean true for all properties of the next custom object
optimization
can also be a custom object
"configurations": {
"optimization": {
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": true
},
"fonts": true
}
switching to "scripts": false
will have as a result the .js files to not be minified
also switching to styles -> "minify": false
will also avoid styles minifying.
Whatever configuration you have in angular.json for optimization, it can be overwritten if you provide a parameter during build. So by executing ng build --configuration=production --optimization=false
it will build your project for production and apply to each property of optimization
object the value false
, which will actually disable minifying for everything.