JavaScript and CSS files in /assets
are not minified after ng build --prod
. Does someone know how I can minify those files? I don't see anything in the angular doc.
Everything you build in production are already minify if it not minify I think you havent turn on configuration in angular.json. You can use these config in your angular.json
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": true,
"buildOptimizer": true,
"serviceWorker": true,
"deleteOutputPath": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
Then run ng build --prod
again
When you run ng build --prod
angular-cli creates a new folder named dist
in your project folder. the dist
is the folder that you upload to your server in order to deploy your project.
the assets folder is not minimized because there is no code to minimize in that folder, angular-cli does not minimize images, svgs text files etc ... if you want to minify images, you can search for online tools such as TinyJPG
edit:
Not necessarily mean that you want to minimize your images, but in your assets
folder there shouldn't be any files which are .js .css .html .ts etc...
only Jsons, images and other assets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With