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

#163967 css alias #368

Merged
merged 15 commits into from
Nov 27, 2023
Merged

#163967 css alias #368

merged 15 commits into from
Nov 27, 2023

Conversation

SStranks
Copy link
Contributor

@SStranks SStranks commented Oct 30, 2023

Issue #163967: [css] Custom aliases in CSS file resolution
In conjunction with Pull Request #197033

Functionality:

Mimicking the alias functionality in ts/jsconfig (compiler.paths) within CSS and SCSS files, allowing ctrl-click file link navigation of aliased import paths.

Changes

cssLanguageService.ts
Applying the settings (as per the aforementioned pull request) to the language service.

cssLanguageTypes.ts
New interface for the required alias settings.

cssNavigation
If a reference file can not be located as a relative import or module (existing code), then attempt to resolve it by testing against the aliases defined in the settings. If the import path matches an alias then return the single file reference, or if the import paths first segment (plus '*' glob) matches an alias then construct a new path (root path + alias path + import path minus first segment).

@SStranks
Copy link
Contributor Author

@microsoft-github-policy-service agree

@aeschli
Copy link
Contributor

aeschli commented Oct 31, 2023

Thanks @SStranks

@aeschli
Copy link
Contributor

aeschli commented Nov 1, 2023

		"alias": {
			"paths": {
				"@SingleStylesheet": "/src/assets/styles.css",
				"@AssetsDir/*": "/src/assets/*",
			}
		}
  • If I understand correctly the aliases can be either files or folders. Folders end with /*. I would suggest annotating the folder with just /. The star might give the impression that patterns are supported at the beginning or in the path as well.
  • Not sure we use two levels (alias and paths). Can it be single importAliases?. Or is this inspired by other tools that use the same notation?

fix(): folder reference now '/' from '/*'
@SStranks
Copy link
Contributor Author

SStranks commented Nov 1, 2023

		"alias": {
			"paths": {
				"@SingleStylesheet": "/src/assets/styles.css",
				"@AssetsDir/*": "/src/assets/*",
			}
		}
  • If I understand correctly the aliases can be either files or folders. Folders end with /*. I would suggest annotating the folder with just /. The star might give the impression that patterns are supported at the beginning or in the path as well.
  • Not sure we use two levels (alias and paths). Can it be single importAliases?. Or is this inspired by other tools that use the same notation?

I've amended all the files in both PR's to take into account your suggestions. The 'two levels' was only because initially I thought there might be need of other options, given what was discussed in this thread.

@aeschli aeschli enabled auto-merge (squash) November 27, 2023 20:58
@aeschli aeschli merged commit 8090d87 into microsoft:main Nov 27, 2023
6 checks passed
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