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

Add support for building on production. #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

izaakschroeder
Copy link
Contributor

Since middleman is actually retarded, we hijack manipulate_resource_list to do the actual font compilation; every SASS file needs to have all its dependants generated by the time this step passes, so this is the only viable entry point. Since the font depends on a directory of files, and not any individual file, we must also monkey patch .template? and .binary? since they only work on regular (non-directory) files. Finally we output the generated fonts as resources in order to keep the Sitemap system happy. no_hash is enabled permanently since it is now the job of :asset_hash.

@izaakschroeder izaakschroeder force-pushed the production_build branch 8 times, most recently from 17352ca to f04ddf9 Compare February 12, 2015 06:46
def manipulate_resource_list(resources)
@compile.call(@options)
resources + [
File.join(@options[:css_dir], "_" + @options[:font_name] + ".scss"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs cleanup to work with other types of outputs.

@izaakschroeder
Copy link
Contributor Author

/ping @uetchy this is ready now and actually works.

@izaakschroeder izaakschroeder force-pushed the production_build branch 2 times, most recently from d12ab79 to 1104118 Compare February 12, 2015 07:05
Since middleman is actually retarded, we hijack `manipulate_resource_list` to do the actual font compilation; every SASS file _needs_ to have all its dependants generated by the time this step passes, so this is the only viable entry point. Since the font depends on a directory of files, and not any individual file, we must also monkey patch `.template?` and `.binary?` since they only work on regular (non-directory) files. Finally we output the generated fonts as resources in order to keep the Sitemap system happy. `no_hash` is enabled permanently since it is now the job of `:asset_hash`.
Conflicts:
	lib/middleman-fontcustom/extension.rb
@uetchy
Copy link
Owner

uetchy commented Feb 12, 2015

Thanks 😃
It looks good but actually doesn't works well on my environment.
I wonder at these changes put css_dir and fonts_dir into "build" dir.
Why "build"?

@izaakschroeder
Copy link
Contributor Author

Since they are generated files, build seems like the place to put them. That way they are, by default, out of the grasps of version control (like git) and they get picked up by the :asset_hash plugin.

Setup middleman:

sprockets.append_path File.join root, "build", "stylesheets"
sprockets.append_path File.join root, "build", "fonts"

activate :fontcustom do |fc|
  fc.font_name = 'icons'
  fc.source_dir = 'source/icons'
  fc.fonts_dir = 'fonts'
  fc.css_dir = 'stylesheets/components'
  fc.templates = 'scss'
  fc.font_design_size = 62 # picas not pixels
  fc.font_ascent = 850
  fc.font_descent = 150
end

Import icons:

@import "components/icons"

@uetchy
Copy link
Owner

uetchy commented Feb 17, 2015

This looks like more rational way.
But I'm concerned about they might be forcing users to use a bit tricky way like append_path
In addition, these changes put litter of 'scss' and 'svg' on build dir.
What do you think about 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

Successfully merging this pull request may close these issues.

3 participants