I implemented a lazy loading module in angular 4. it works well. and when I go to a new page, it will load an additional js file, for example: 0.chunk.js, 1.chunk.js.
my question is: how to change this piece name? for example: 1.chunk.js => about.js 0.chunk.js => user.js
So far, the only way I know how to name lazy loaded chunks is to use the webpack configuration outside of the Angular CLI with the angular-router-loader package:
https://github.com/brandonroberts/angular-router-loader/blob/master/docs/options.md#lazy-loading-options
webpack.config.js
{ test: /\.ts$/, loaders: [ { loader: 'awesome-typescript-loader', options: { configFileName: helpers.root('src', 'tsconfig.json') } }, 'angular-router-loader', 'angular2-template-loader' ] }
:
{ path: 'lazy', loadChildren './lazy.module#LazyModule?chunkName=MyChunk' }
, Angular cli. : https://github.com/angular/angular-cli/issues/5171
@angular/cli 1.3.0-beta. your-lazy-loading.module.chunk.js. , , npm install -g @angular/cli@1.3.0-beta.1 package.json
your-lazy-loading.module.chunk.js
npm install -g @angular/cli@1.3.0-beta.1
package.json
devDependencies": { "@angular/cli": "1.3.0-beta.1", ... }
, npm install. , !
npm install
, Webpack Angular.
webpack.config "output".
(ex):
const DistDirectory = path.resolve(__dirname, '../dist'); ..., output: { path: DistDirectory, filename: '[name].[hash].bundle.js' }
: 0.89872d7bedaacc90c95a.bundle.js
, .
P/s: angular -cli ,
Source: https://habr.com/ru/post/1017133/More articles:Changing language in iOS app in auto layout - iosHow to lock a drawer for a specific page using drawerNavigation [react-navigation] [react-native] - react-nativeEspresso: нет представлений в иерархии, найденных совпадением с id: android: id/home - androidSOAP Service Client Generated Using the WSDL Signing Module Only - c #What does an override application url really do? - c #How to send document file in JSQMessageViewController? - iosWhy is Docker Compose restart able to display container contents more often? - phpDocking Supervisor Alternative - dockerHow to get a list of property names in a class in a specific order - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1017138/what-is-a-p2-repository&usg=ALkJrhhZLAbPtoxbs-7AjlXlla2nitoGMwAll Articles