title: How to minify Angular 8 Dev Build
body: <p>By default Angular CLI (ver-8) does not remove the comments and minify js dev build generated files. (main.js,vendor.js,scripts.js etc).</p>
  <p>We are importing JitCompiler so need Dev Build with optimized generated output files(vendor.js, main.js ect)</p>
  <p>I have added my own webpack file webpackext.config.js. and using it through &quot;@angular-builders/custom-webpack:browser. I am able to remove comments from generated files  using below configuration. I need to also minify generated files using some plugin. How can we do that, need information about plugins and configuration method as well.</p>
  <pre><code>const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  const path = require(&quot;path&quot;);
  
  module.exports = {
    entry: './src/main.js',
    output: {
      filename: '[name].bundle.js',
      path: path.resolve(__dirname, 'dist')
    },
    plugins: [
      new UglifyJsPlugin({
        uglifyOptions: {
       
          output: {
            comments: false
          }
  
        }
      })
    ]
  }  
  </code></pre>
  <p><strong>Why we need this</strong>: We are loading lazy loaded module using Require JS. Lazy loaded module(sample.module.js) is placed by end user.  They generates lazy loaded module from their application. As importing jit compiler to our system to create end user's  component on demand so we can not go with production build . We have upgraded our system from angular 4 to angular 8.  Earlier on Angular 4,  all the js files are minified. But in Angular 8, js file's size are increased to double.</p>
  <pre><code>    require.ensure(
            [&quot;assets/samples/sample.module.js&quot;], 
            (require) =&gt; {
              let SampleCo = require(assets/samples/sample.module.js&quot;);
              this._compiler
                .compileModuleAndAllComponentsAsync(
                  SampleCo.SampleCustomModule
                ).then((compiled) =&gt; {
                  const component1 = compiled.componentFactories.find(
                    (m) =&gt; m.selector == &quot;sample-comp1&quot;
                  );    });
                //here we create component with ViewContainerRefr
            },
            &quot;custom/sampleLib&quot; 
  }
  </code></pre>
  <p>After using UglifyJsPlugin, generated js files are minified. However getting error while loading system, error as below</p>
  <pre><code>Uncaught Error: Can't resolve all parameters for hC: (?).
      at Li (vendor.js:1)
      at n_._getDependenciesMetadata (vendor.js:1)
      at n_._getTypeMetadata (vendor.js:1)
      at n_.getNgModuleMetadata (vendor.js:1)
      at n_.getNgModuleSummary (vendor.js:1)
      at vendor.js:1
      at Array.forEach (&lt;anonymous&gt;)
      at n_.getNgModuleMetadata (vendor.js:1)
      at n_.getNgModuleSummary (vendor.js:1)
      at vendor.js:1
  </code></pre>