finsweet / developer-starter

Developer starter template for Finsweet projects.
https://www.finsweet.com/
187 stars 67 forks source link

Create multiples files when I build a project with pnpm build. #32

Closed initweb-fr closed 1 year ago

initweb-fr commented 1 year ago

Hi !

Is there a way with the Developer Starter Template to create multiples bundles when I 'pnpm build' ?

I was wondering if we can have a main index.js that will load in the Webflow Project Settings and an index-thisTypeOfPage.js for specific pages. With this I can have a large amount of page loading superfast with only the index.js, and a few more robust pages loading the everything with index.js + the special needs with index-thisTypeOfPage.js.

Trully love your work ! Have a great day ! 🙏

robertkibet commented 1 year ago

Hello @monolithstd, is this what you are looking for?

See this line: https://github.com/finsweet/developer-starter/blob/master/bin/build.js#L9

You can have your entry points setup like this:

const ENTRY_POINTS = [
   'src/index.ts',
   'src/another/page.ts',
   'src/utils/index.ts',
   'src/settings/auth.ts',
   // add more entry points
];

then when you run pnpm dev, you can get your bundled outputs like:

Built files: [  
  'http://localhost:3000/index.js',
  'http://localhost:3000/another/page.js',  
  'http://localhost:3000/utils/index.js',
  'http://localhost:3000/settings/auth.js',
  ]

and when you pnpm build, you'll get the respective bundled outputs as set in your entry points.

alexiglesias93 commented 1 year ago

Thank you for answering @robertkibet . @monolithstd if your question was solved, I'll proceed to close this issue.