In a traditional server-rendered app you might not have a single main entry point. Rather you have a different main for each page. We call this a multi-main project. With steal you can use a different main for each page in your application.
For example, you might have a home.html with this:
Notice here that there is a bit of duplication. Because each of these bundles is an entry point it needs to contain everything needed to configure itself, which will include the npm plugin.
Looking at the dist folder created, it should like this:
In a traditional server-rendered app you might not have a single main entry point. Rather you have a different main for each page. We call this a multi-main project. With steal you can use a different main for each page in your application.
For example, you might have a home.html with this:
And a login.html with this:
With steal-tools you can create a build that puts all of these mains into their own modules.
API
Multi-main app use the same APIs to build as single page apps.
Additionally see StealConfig about how
main
can be an Array (which it will be in a multi-main app).Using multi-main
To create a multi-main build, you need a build script. If you don't already have one, create build.js:
Then if you run this script:
Which should output this:
Notice here that there is a bit of duplication. Because each of these bundles is an entry point it needs to contain everything needed to configure itself, which will include the npm plugin.
Looking at the dist folder created, it should like this: