-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Feature rewrite-urls #3041
Feature rewrite-urls #3041
Conversation
- Rename isPathRelative to pathRequiresRewrite - Add special handling for rewriteUrls=relative - Add rewritePath for path rewriting - Ensure that explicit relative paths stay explicit relative - Remove code style inconsistencies
return newPath; | ||
}; | ||
|
||
contexts.Eval.prototype.normalizePath = function (path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in normalizePath
are just code style issues
Doesn't look like CI fails are related to these changes... |
👍
|
I can add that.
I do understand. I just felt like Then we would have: |
Or is |
|
I'm also not a fan of So, it sounds like there's still a problem on the naming/semantics front. |
I think no, we don't. But I'm afraid by now we might already have some drift in expectations of which option is doing what exactly... Probably a table of results of every option for every path ("abs://foo", "../foo", "./foo", "foo") would be helpful. |
I can't think of a use-case. I really like If you agree on
Yes, especially in conjunction with the |
What's the status of this? |
I was waiting for feedback on the |
I think we just need weigh-in from @seven-phases-max. Then hopefully you could proceed and merge this (although there are a few conflicts now). |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Pinging @less/core again for this. |
Well, I put |
@seven-phases-max 🤔 Hmm... I'm not certain it's breaking. It seems to have appropriate backwards-compatibility fallbacks, but as the task runners were changed, it's hard to verify that it ISN'T breaking. That is, lines like this suggest it is a breaking change, but it would be better to mix the two i.e. show that So, yeah, maybe some clarification on this PR (and tests demo-ing both feature implementation and backwards compatibility) would be helpful. |
@jhnns Are you still able to resolve this and answer the above questions? |
Yes, I can work on this the next days 👍 Regarding your questions: I have to look into it again, but I think it's not a breaking change as the old option is still available as So, I'll use |
Sure I could miss something. So... if some external code passes |
- Rename explicit-relative to local - Add rewrite-urls argument validation - Replace unknown CSS property background-url with background-image Based on discussion less#3041
- Remove redundant tests - Add rootpath-rewrite-urls-all test - Add rootpath-rewrite-urls-local test
c8f65df
to
2a4dfec
Compare
} | ||
|
||
var j = file.lastIndexOf('/'); | ||
if (newFileInfo.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) { | ||
if (newFileInfo.rewriteUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we need to change that part. However, for me it looks like less.Parser.fileLoader
is not used anywhere. Is that file even up-to-date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, less-rhino
should have been pulled in 3.0, but I just wasn't sure. I doubt it even still works. Ideally, PR #2985 should be re-written and pulled into its own repo with less
as a dependency (as in https://github.com/less/less-java
), and then less-rhino
should be removed as a sub-folder.
Long and short, there aren't any active Java maintainers in the Less core team, so we really can't manage it within this repo.
I resolved the merge conflicts, changed the options to The PR is almost done from my point of view. If used from the command line (via I'd appreciate some help here so that we can finally merge that feature :) |
Thanks for your work in re-working this! I'll see if I can take a look sometime soon, but anyone else is welcome to take this one of course. |
* Rename relativeUrls option to rewriteUrls * Refactor contexts.js - Rename isPathRelative to pathRequiresRewrite - Add special handling for rewriteUrls=relative - Add rewritePath for path rewriting - Ensure that explicit relative paths stay explicit relative - Remove code style inconsistencies * Add missing tests for url rewriting * Rename rewrite-urls option value to explicit-relative * Add missing tests for url rewriting * Refactor rewrite urls options - Rename explicit-relative to local - Add rewrite-urls argument validation - Replace unknown CSS property background-url with background-image Based on discussion #3041 * Re-add tests for deprecated relative-urls option * Improve tests - Remove redundant tests - Add rootpath-rewrite-urls-all test - Add rootpath-rewrite-urls-local test * Fix typo in unknown argument warning * Revert old tests to deprecated relativeUrls option again * Added more CSS Grid tests * All tests passing * Merge branch 'master' into feature/rewrite-urls (#3282) * WIP - Added strictMath: 'division' option * Removes `less-rhino` (broken for a long time) - Fixes #3241 * Expressions require a delimiter of some kind in mixin args * Removes "double paren" issue for boolean / if function * WIP each() re-implementation * Allows plain conditions without parentheses * Added each() and tests * Added tests calling mixins from each() * Fixes #1880 - Adds two new math modes and deprecates strictMath * Allows named args for detached ruleset (anonymous mixin) * Makes sure this doesn't regress needing parens around mixin guard conditions * Remove javascriptEnabled from browser options check, add to defaults * Workaround weird Jasmine conversion of < to HTML entity * Removes remaining Rhino cruft * Remove rhino files from bower * Bump Jasmine version * Added .() example to each * v3.6.0 * Update CHANGELOG.md * add explicit nested anonymous mixin test * add explicit nested anonymous mixin test result * derp: align test with expected output * v3.7.0 (#3279) * Update CHANGELOG.md * Rewrite the rewriteUrls feature to use same pattern as strictMath-to-math * Update console warning for --relative-urls
This PR is based on the discussion #2615. It introduces a new option called
rewrite-urls
that can have two possible values:all
: Rewrite allurl()
statements to the base less fileexplicit-relative
: Only rewriteurl()
statements that start with a.
. This enables CSS modules supportThe option is disabled by default. The option
relative-urls
is superseded byrewrite-urls=all
.As a side-effect, this PR also introduces a second change: Explicit relative URLs stay explicit relative – irregardless of the
rewrite-url
option. Check out the changes intest/css/static-urls/urls.css
andtest/css/urls.css
.