Angular 2 (Cli) does not reduce asstet / css files

I created a project with Angular 2 using Angular-cli . When i started

    ng build --prod

I do not have js and css files. These files are located in assets / js / and assets / css / .

How can I minimize them? Thank!

+4
source share
2 answers

the resource folder is included in your assembly because the folder is listed in the asset array in angular-cli.json.

everything in the asset array is copied "as is" on the assembly.

if you add your css and scripts to -arrays styles and scripts in angular-cli.json, they will be added to the assembly so that all your css are in styles.bundle.js (yes js).

css js index.html, angular -cli index.html.

, , , " ", , (, https://www.npmjs.com/package/minifier) angular -cli , .

+5

js angular -cli.json

"styles": [
    "assets/css/style.css",
    "assets/css/fonts.css"
],
"scripts": [
    "assets/js/app.js",
    "assets/js/other.js"
]
+1

Source: https://habr.com/ru/post/1663407/


All Articles