From 30b54690cfde74474ee8307d79bf65e870757b7d Mon Sep 17 00:00:00 2001 From: Alasdair McLeay Date: Mon, 18 Mar 2019 12:09:30 +0000 Subject: [PATCH] add some documentation --- .../server/src/utils/documentContext.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/css-language-features/server/src/utils/documentContext.ts b/extensions/css-language-features/server/src/utils/documentContext.ts index 810b7070028..1de06b726ec 100644 --- a/extensions/css-language-features/server/src/utils/documentContext.ts +++ b/extensions/css-language-features/server/src/utils/documentContext.ts @@ -40,11 +40,15 @@ export function getDocumentContext(documentUri: string, workspaceFolders: Worksp } } } + // Following [css-loader](https://github.com/webpack-contrib/css-loader#url) + // and [sass-loader's](https://github.com/webpack-contrib/sass-loader#imports) + // convention, if an import path starts with ~ then use node module resolution + // *unless* it starts with "~/" as this refers to the user's home directory. if (ref[0] === '~' && ref[1] !== '/') { const moduleName = getModuleNameFromPath(ref.substring(1)); const modulePath = require.resolve(moduleName, { paths: [base] }); - const pathInModule = ref.substring(moduleName.length + 2); - return url.resolve(modulePath, pathInModule); + const pathWithinModule = ref.substring(moduleName.length + 2); + return url.resolve(modulePath, pathWithinModule); } return url.resolve(base, ref); },