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

Multiple //= require statements in JS/CSS in JEKYLL_ENV=development should result in multiple <script>/<link>s, like in Rails #597

Open
1 task
Nowaker opened this issue Jun 10, 2019 · 7 comments

Comments

@Nowaker
Copy link
Contributor

Nowaker commented Jun 10, 2019

  • This feature is not on the latest version

  • jekyll 3.8.5

  • jekyll-assets: 3.0.12

Request

Cite from Rails documentation

Source.

In development mode, assets are served as separate files in the order they are specified in the manifest file.

This manifest app/assets/javascripts/application.js:

//= require core
//= require projects
//= require tickets

would generate this HTML:

<script src="/assets/core.js?body=1"></script>
<script src="/assets/projects.js?body=1">
</script><script src="/assets/tickets.js?body=1"></script>

Explanation

The way it's implemented in Rails is best suited for development:

  1. Fast reloads - no need to compile the whole tree (SCSS + its all nested requires), as each asset is accessed directly, and can re-use the cache when a file has not changed.
  2. Convenient in development - no need for sourcemaps when working on direct source code.
  3. Resolves a problem with --incremental builds in Jekyll when modifying blah.js that is //= required by main.js. Changes to a JavaScript file included with //= require not reflected when using Jekyll's --incremental rebuild #596

Thanks for considering this! And thank you for jekyll-assets!

@Nowaker Nowaker changed the title Multuple //= require statements in JS/CSS in JEKYLL_ENV=development should result in multiple <script>/<link>s, like in Rails Multiple //= require statements in JS/CSS in JEKYLL_ENV=development should result in multiple <script>/<link>s, like in Rails Jun 10, 2019
@envygeeks
Copy link
Owner

This would be a Sprockets issue as we don't directly provide requires.

@Nowaker
Copy link
Contributor Author

Nowaker commented Jun 13, 2019

I don't know if what Rails does is part of Sprockets, or custom Rails code wrapping Sprockets to achieve this result.

All in all, this issue is meant to be a feature request, not a bug report, so please consider this as an option in the future. Thanks!

@envygeeks
Copy link
Owner

Since Sprockets does all of the //= logic on our behalf the request would have to go through them, Rails would indeed support it through them so you'll have to provide more debug logs to show how it's broken and then I can talk with Scheems and see what's going on.

@Nowaker
Copy link
Contributor Author

Nowaker commented Jun 21, 2019

@envygeeks I don't understand your request. I didn't say anything's broken. This is a feature request.

@envygeeks
Copy link
Owner

Is there a benefit to doing this @Nowaker?

@envygeeks envygeeks self-assigned this Mar 6, 2020
@envygeeks envygeeks added this to the Someday milestone Mar 7, 2020
@Nowaker
Copy link
Contributor Author

Nowaker commented Mar 7, 2020

@envygeeks The three points in Explanation part of the ticket are the benefits.

@envygeeks
Copy link
Owner

envygeeks commented Mar 7, 2020

# 1 isn't an issue Sprockets won't recompile the whole tree (or shouldn't)
# 2 is only mitigated in certain circumstances (and only for Pure JS that isn't transpiled, or CSS)
# 3 is a whole other ticket

That's why I asked if there were any better reasons.

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

No branches or pull requests

2 participants