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 10a8f427c..537e5e3a5 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 000000000..39ec289a4 --- /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); + }); +});