From 08c97de72a29cf14e868268b78b95c83db9a6597 Mon Sep 17 00:00:00 2001 From: Bryce Osterhaus Date: Thu, 21 Mar 2024 09:46:00 +0400 Subject: [PATCH] will squash before merge: --- .../src/utils/webpackScssLoader.js | 5 ++- .../test/utils/webpackScssLoader.js | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 projects/npm-tools/packages/npm-scripts/test/utils/webpackScssLoader.js diff --git a/projects/npm-tools/packages/npm-scripts/src/utils/webpackScssLoader.js b/projects/npm-tools/packages/npm-scripts/src/utils/webpackScssLoader.js index 10a8f427cb..537e5e3a54 100644 --- a/projects/npm-tools/packages/npm-scripts/src/utils/webpackScssLoader.js +++ b/projects/npm-tools/packages/npm-scripts/src/utils/webpackScssLoader.js @@ -15,7 +15,10 @@ module.exports = function (_content, _map, _meta) { const webContextPath = getBndWebContextPath(projectDir); - let urlPath = path.relative(buildConfig.input, resourcePath); + let urlPath = path.posix.relative( + buildConfig.input, + resourcePath.split(path.sep).join(path.posix.sep) + ); urlPath = urlPath.replace(/scss$/, 'css'); diff --git a/projects/npm-tools/packages/npm-scripts/test/utils/webpackScssLoader.js b/projects/npm-tools/packages/npm-scripts/test/utils/webpackScssLoader.js new file mode 100644 index 0000000000..39ec289a45 --- /dev/null +++ b/projects/npm-tools/packages/npm-scripts/test/utils/webpackScssLoader.js @@ -0,0 +1,39 @@ +/** + * SPDX-FileCopyrightText: © 2019 Liferay, Inc. + * SPDX-License-Identifier: BSD-3-Clause + */ + +const os = require('os'); + +describe.only('windows test', () => { + it('returns relative path', () => { + const basePath = 'src/main/resources/META-INF/resources'; + + const resourcePath = path.join( + os.tmpdir(), + 'src', + 'main', + 'resources', + 'META-INF', + 'resources', + 'js', + 'pages', + 'RuleList.scss' + ); + + console.log('RESOURCE: ', resourcePath); + + let oldPath = path.relative(basePath, resourcePath); + + console.log('OLD: ', oldPath); + + let newPath = path.posix.relative( + basePath, + resourcePath.split(path.sep).join(path.posix.sep) + ); + + console.log('NEW: ', newPath); + + expect(oldPath).toBe(newPath); + }); +});