Can angular-cli remove unused css?

后端 未结 6 1471
时光说笑
时光说笑 2020-12-23 21:22

so far the smallest bundle I can create with angular cli is by running

ng build --aot true -prod

I was wondering if the build p

6条回答
  •  情歌与酒
    2020-12-23 22:03

    If you are ejected, i.e. ng eject. Then you can customize the webpack build to do most anything. I have a couple options turned on to minimize styles as part of the build with minifyCSS in two of the plugins.

    1. LoaderOptionsPlugin

      new LoaderOptionsPlugin({
        "sourceMap": false,
        "options": {
          "html-minifier-loader": {
              "removeComments": true,
              "collapseWhitespace": true,
              "conservativeCollapse": true,
              "preserveLineBreaks": true,
              "caseSensitive": true,
              "minifyCSS": true
          },
      
    2. HtmlWebpackPlugin

      new HtmlWebpackPlugin({
        "template": "./src\\index.ejs",
        "filename": "./index.html",
        "hash": true,
        "inject": true,
        "compile": true,
        "favicon": 'src/assets/Flag.png',
        "minify": {
            collapseWhitespace: true,
            removeComments: true,
            minifyCSS: true
          },
      

提交回复
热议问题