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

Generate compiled stylesheets / js #183

Merged
merged 18 commits into from
May 25, 2020
Merged

Generate compiled stylesheets / js #183

merged 18 commits into from
May 25, 2020

Conversation

bencalegari
Copy link
Contributor

#176

Run rake assets:package to get the compiled stylesheets, js, and maps for honeycrisp.

Ben Calegari and Luigi Ray-Montanez and others added 15 commits May 12, 2020 09:49
[#166]

Signed-off-by: Luigi Ray-Montanez <[email protected]>
- Add yui-compressor gem to minify js
- yui-compressor didn't have an option to create source maps, so i
  tailored a solution from this blog-post:
- https://blog.experteer.engineering/generating-sourcemaps-with-sprockets-3-and-uglify.html
[#176]
[#176]

Signed-off-by: Luigi Ray-Montanez <[email protected]>
- Turns out this isn't the right way to use sourcemaps but it doesn't
  break anything so we're going to roll forward.

[#176]
@hartsick hartsick temporarily deployed to honeycrisp-generate-dis-sjzk4f May 12, 2020 18:02 Inactive
@luigi luigi requested a review from lkogler May 14, 2020 16:05
Copy link
Contributor

@lkogler lkogler left a comment

Choose a reason for hiding this comment

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

Mostly this looks good to me; however, I did encounter some unexpected results when running rake assets:package.

  1. I would have expected the file dist/css/honeycrisp.css to be a concatenation of all our css files (after conversion from scss). However, instead it seems to be a list of @import statements.
  2. I would have expected the file dist/css/honeycrisp.min.css to be a minified version of honeycrisp.css (i.e. removing comments and whitespace); however, it looks to me like honecrisp.min.css is simply a concatenated css file (similar to what I expected honeycrisp.css to be) -- it doesn't look minified to me.

Am I missing something? Let me know!

assets = sprockets.find_asset(STYLESHEET_PATH)
assets.write_to("#{CSS_PATH}/honeycrisp.css")

sprockets = create_sprockets_env(compress: true)
Copy link
Contributor

@lkogler lkogler May 16, 2020

Choose a reason for hiding this comment

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

I don't think these three lines (48-50) are doing anything -- it seems to behave exactly the same with them commented out...

Ruby sass, which sass-rails relies on was end of life as of 26 Mar
2019. More here: https://sass-lang.com/ruby-sass

sassc-rails and SassC are supposed to be good replacements.

https://github.com/sass/sassc-rails
@hartsick hartsick temporarily deployed to honeycrisp-generate-dis-sjzk4f May 22, 2020 00:41 Inactive
In theory we should be able to do this with the SasscCompressor, but I
couldn't get it to work so instead just used the SassCEngine directly.
@hartsick hartsick temporarily deployed to honeycrisp-generate-dis-sjzk4f May 22, 2020 00:45 Inactive
@hartsick
Copy link
Contributor

I did some work on this that I think fixes the CSS compilation, minification, and source map creation. Right now rake assets:package runs successfully and generates what look like the CSS files I'd expect:

  • dist/css/honeycrisp.css
  • dist/css/honeycrisp.css.map
  • dist/css/honeycrisp.min.css
  • dist/css/honeycrisp.min.css.map

Some things that may be worth following up on:

  • I haven't verified that the sourcemaps are correct, just that they're generated—probably should make sure they associate correctly when used in a project
  • I'm generating a source map for both compiled CSS (minified & unminified). Not sure if we prefer to just generate one for minified, which is what we're doing for JS now

@lkogler lkogler temporarily deployed to honeycrisp-generate-dis-sjzk4f May 25, 2020 23:07 Inactive
@lkogler
Copy link
Contributor

lkogler commented May 25, 2020

This looks good to me @hartsick.

The only update I made was to use style "compressed" fully minify the css file.

I played around with getting the sourcemaps loaded in a toy project, but wasn't able to get it to work without monkeying around with the paths a bit (it seems that my browser was expecting the sourcemap file path to be relative to the css file, not relative to the project root; also, I think we might want it to point to the dist/scss directory rather than app/assets for the source files, since I think the use case here is that someone is copying our dist folder into a non-rails project. However, I think we can leave these questions about the sourcemaps until we have an actual use case, rather than hypothesizing about how someone might want to use it.

I'm going to merge this PR and call it done for now. We can revisit the sourcemap question if/when we have a need for it.

@lkogler lkogler merged commit 570da7c into master May 25, 2020
@lkogler lkogler deleted the generate-distro branch May 25, 2020 23:18
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