17

I'm using angular-cli-1.6.3 for bundling my project. I try to rename lazy loaded chunk name into valid module name. But it is not working. Code snippet given below,

{
  path: 'lazy',
  loadChildren: './lazy/module#LazyModule?chunkName=LazyModule'
}
2
  • why are you using ?chunkName=LazyModule? where did you got that from? Commented Jan 29, 2018 at 7:58
  • I saw some sample. But now i removed that. Commented Jan 29, 2018 at 9:06

2 Answers 2

25

you should be using -nc flag

ng build --aot -nc

or

ng build --aot --named-chunks

Update 1 : Based on Comment

to remove the hash numbers set the --output-hashing to false as below

ng build --aot --nc --output-hashing=false

Documentation Link

Sign up to request clarification or add additional context in comments.

13 Comments

Throwing error like: ERROR in Error: LazyModule?chunkName=LazyModule is not an NgModule
it simply created a file like "module.ebc4664b446ca766a851.chunk.js". But i want module name as file name or custom name. Do needful
no it created like this only "module.ebc4664b446ca766a851.chunk.js". What to do? Im using angular-cli-1.6.3
Rename that too lazy.module.ts
Hey everyone! The chunks have hashes for a reason. What if you update your app and people still have it open? They'll get the OLD compatible hashed file instead of loading a new file with the same name that may not be compatible. If you have files on a CDN they may get cached too - so having unique filenames per version is much safer.
|
5
 ng build --namedChunks=true --outputHashing=none --vendorChunk=true
  • namedChunks Use file name for lazy loaded chunks
  • output-hashing Define the output filename cache-busting hashing mode.
  • vendorChunk Use a separate bundle containing only vendor libraries.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.