From b769fbbc9925fd8973ab79796d0b963a4c4f9308 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Smyrek?=
Date: Wed, 4 Nov 2020 08:08:22 +0100
Subject: [PATCH] Fixed paths for styles and scripts in snippet adapter
---
package.json | 1 +
scripts/docs/snippetadapter.js | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 42d34951d71..bf0b805daa9 100644
--- a/package.json
+++ b/package.json
@@ -116,6 +116,7 @@
"svgo": "^1.3.2",
"terser-webpack-plugin": "^3.0.2",
"umberto": "^1.5.4",
+ "upath": "^2.0.0",
"webpack": "^4.43.0"
},
"engines": {
diff --git a/scripts/docs/snippetadapter.js b/scripts/docs/snippetadapter.js
index ec722a0e4d3..390170ccfe8 100644
--- a/scripts/docs/snippetadapter.js
+++ b/scripts/docs/snippetadapter.js
@@ -6,6 +6,7 @@
/* eslint-env node */
const path = require( 'path' );
+const upath = require( 'upath' );
const fs = require( 'fs' );
const minimatch = require( 'minimatch' );
const webpack = require( 'webpack' );
@@ -513,7 +514,8 @@ function readSnippetConfig( snippetSourcePath ) {
}
/**
- * Removes duplicated entries specified in `files` array and map those entires using `mapFunction`.
+ * Removes duplicated entries specified in `files` array, unifies path separators to always be `/`
+ * and then maps those entries using `mapFunction`.
*
* @param {Array.} files Paths collection.
* @param {Function} mapFunction Function that should return a string.
@@ -521,6 +523,7 @@ function readSnippetConfig( snippetSourcePath ) {
*/
function getHTMLImports( files, mapFunction ) {
return [ ...new Set( files ) ]
+ .map( path => upath.normalize( path ) )
.map( mapFunction )
.join( '\n' )
.replace( /^\s+/, '' );