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

Need to remove files from dist, unable to update context.distFiles #457

Open
lolmaus opened this issue Feb 19, 2017 · 7 comments
Open

Need to remove files from dist, unable to update context.distFiles #457

lolmaus opened this issue Feb 19, 2017 · 7 comments

Comments

@lolmaus
Copy link

lolmaus commented Feb 19, 2017

Current logic always appends to arrays in the context, making it impossible to remove entries from context.distFiles:

if (_.isArray(a)) {
return a.concat(b);
}

I've managed to monkey patch it like this and it worked:
https://github.com/lolmaus/lolma.us/blob/b7c1163dccab5d21c4bc4245b0483da5f698fa4a/lib/ember-cli-deploy-manipulate/index.js#L13-L20

I can try adding a test case and filing a pull request. Need confirmation, recommendations welcome.

@LevelbossMike
Copy link
Member

LevelbossMike commented Feb 20, 2017

Can this logic be implemented by tapping into ember-cli's build-hooks directly instead? Manipulating the build in another plugin seems like a suboptimal solution to me as the actual build is configured in ember-cli-build.js. I had success in adding specific files to the build via addon-hooks via in-repo-addons in the past.

Was that impossible in your particular use-case (removing instead of adding of course)?

@lolmaus
Copy link
Author

lolmaus commented Feb 20, 2017

Not with StaticBoot, unfortunately. StaticBoot produces a separate static build in a subfolder. The subfolder is configurable, but it can't be set to dist root.

Also, the ability to modify arrays on context is a general feature not limited to this use case or this deploy step.

@lukemelia
Copy link
Contributor

We knew that this was a potentially limiting aspect of our approach to the context object merges but had yet to run into a real world use case where it was an issue. The solution merits API discussion.

Currently, the ember-cli-deploy "way" to think about this is not to think about removing files from context.distFiles but rather to configure the plugin that is consuming distFiles to exclude the files you wish to.

@lolmaus
Copy link
Author

lolmaus commented Feb 20, 2017

With the proposed feature, I can simply create a deploy addon that removes files from the dist. This will work for any consuming addon.

With configure the plugin that is consuming distFiles to exclude the files you wish to, I have to:

  • persuade a maintainer of the consuming addon that a filtering feature is necessary (I bet a pint that he will pass the buck back at you);
  • implement a failing test case;
  • implement the feature;
  • file a PR, have it reviewed and merged.

Repeat for every consuming addon.

After having this done for a few addons, one would naturally consider extracting the filtering feature into a reusable addon — and we're back to where we started.

I want to emphasize again that the feature is not limited to removing files from dist. It is useful for any other potential use case where any array on context has to be modified rather than added to.

lolmaus added a commit to lolmaus/ember-cli-deploy that referenced this issue Feb 20, 2017
lolmaus added a commit to lolmaus/ember-cli-deploy that referenced this issue Feb 20, 2017
@lolmaus
Copy link
Author

lolmaus commented Feb 20, 2017

We knew that this was a potentially limiting aspect of our approach to the context object merges but had yet to run into a real world use case where it was an issue.

Let me tell you about one use case.

ember-cli-staticboot is an addon that allows using Ember as a generator of static websites, with optional "hydration". Essentially, a backendless FastBoot.

The most natural use case is deploying the website to GitHub Pages. It even substitutes for lack of URL rewriting!

There are three ember-cli-deploy addons that deploy to GitHub Pages and none of them support filtering distFiles or choosing a subfolder to deploy, neither does pagefront. s3 allows choosing a subfolder, but ironically it requires distFiles to be relative to the subfolder.

ember-cli-staticboot allows configuring the subfolder, but it cannot be set to dist root, overwriting main Ember assets. It has to be done after the build.

Thus, this issue prevents ember-cli-deploy from being used for deploying an ember-cli-staticboot-driven website, which is a huge loss.

You can't realistically expect every addon to account for this use case, and the fact that "you knew" only makes it worse. Modifying distFiles has to be done by ember-cli-staticboot itself, not by everyone else.

I've filed a PR that allows that: #459. Here's my website deployed using it: http://lolma.us (try it with and without JS).

lolmaus added a commit to lolmaus/ember-cli-deploy that referenced this issue Feb 20, 2017
lolmaus added a commit to lolmaus/ember-cli-deploy that referenced this issue Feb 20, 2017
@lukemelia
Copy link
Contributor

@lolmaus What are the three ember-cli-deploy addons that that you are referring to? I'm sympathetic to your request but want to make sure I understand the constraints and that we evaluate some possible APIs to accomplish this.

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

3 participants