Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What if I care about the anatomy of cartero's output directory? #48

Open
mediafreakch opened this issue Dec 21, 2015 · 6 comments
Open

Comments

@mediafreakch
Copy link

Is there a way to influence how cartero outputs things into the output directory? I don't like the current approach that fingerprints folders and files. Cartero is not the last step in the build process, that's why a predictive file structure matters.

How about factoring this part out into a separate module that can be plugged into cartero optionally (or switching it off via options)?

I'm only interested in concatenating and factor out common modules between different entry points and asset types...

@dgbeck
Copy link
Member

dgbeck commented Dec 22, 2015

Hi @mediafreakch !

The fingerprinting used in the current output directory scheme was implemented with certain requirements in mind - for example, to ensure that each package together with a unique set of package dependencies has a unique path. Although there are different directory structures that could be used, it would be easy to break functionality if those requirements were not met.

However if you listen for the fileWritten event, you could in theory copy any output bundles or assets to whatever directory structure you'd like. Does that approach / event give you the information you need to put things where you want them?

Thx!

@mediafreakch
Copy link
Author

@dgbeck Could be a workaround yes.

Just to clarify where this need comes from: We were looking at using the factor-bundle along with parcelify, and from what I understand cartero managed to combine those two. Can you confirm that with cartero not only JS assets but also CSS is factored out to a common bundle? Docs only state that:

cartero also separates out any JavaScript assets that are used by all your entry points into a common bundle

An example would be that both pageA and pageB contain CSS. And both rely on a moduleC which also contains CSS. At the end I'd expect a bundleA.css, bundleB.css and a bundle common.css when running cartero on A and B entry points.

@dgbeck
Copy link
Member

dgbeck commented Dec 29, 2015

Gotcha. Interesting.

Can you confirm that with cartero not only JS assets but also CSS is factored out to a common bundle?

Right now it is just the shared JS assets that are factored out into a common bundle right now. However, factoring out CSS assets into a common bundle seems both very in scope and doable.

However, it seems that parcelify is the better tool for your needs, and that using cartero in this instance is a rather round-a-bout work around. Can you confirm you would benefit from having an extra option for parcelify, say, commonBundles, that accepts a hash of common bundle paths by asset type, e.g.

{
  script : './common.js',
  style : './common.css'
}

Thanks!

@mediafreakch
Copy link
Author

@dgbeck That sounds about awesome if parcelify would support such an option! So to factor out common JS + common CSS with parcelify I would use the bundlesByEntrypoint combined with the commonBundles options programmatically?

Guess that this would make using the factor-bundle module directly obsolete (when using parcelify)...

@mediafreakch
Copy link
Author

@dgbeck How can we continue from here?

@dgbeck
Copy link
Member

dgbeck commented Jan 7, 2016

Hi @mediafreakch . Good point. I think the proper way to do this is to support the css case through parcelify and leave the js case for browserify and factor bundle. So commonBundles behaves as described above, but just for the types of assets that are under the parcelify umbrella (i.e. css )

{
  style : './common.css'
}

And in fact, we could just use the bundles hash, since that is currently un-used in the case that bundlesByEntrypoint is supplied.

At this point I'm sold on the API and concept. It's just a bandwidth issue now. I'm not sure when I can get to this, the idea is great and the path is clear. We can also try to work on it on this end over the next couple of weeks, but you are welcome to do a PR as well. Keep us posted if you start working on a PR so we don't double up.

Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants