Webpack Chunks - tetloose/tetloose-wp GitHub Wiki
When creating a new component for the project, you need to make the component available to Webpack as a chunk. These components get added to a global Object thats run though an intersection observer, this observer watches until the component is visible on the screen, then it will load its associated files.
Creating a new Chunk
For example when adding a new component called My Component:
See: src/config/modules.config.ts and add a new line.
MyComponent: () => import(/* webpackChunkName: "my-component" */ '@components/my-component/my-component.component')
MyComponentthis is the reference to the TS Class, this needs to be TitleCase.my-componentthis is the reference to the exported JS file, lower-hyphenate-case.'@components/my-component/my-component.component'this is where the component .ts is stored.
The naming convention is very important for step 3, {component-name}.{component}.