From aa777d3502219ccf6117186501eb0fcd47853de6 Mon Sep 17 00:00:00 2001 From: TheLonelyAdventurer Date: Wed, 7 Jul 2021 11:18:34 +0200 Subject: [PATCH] Fixes Does not work on Windows #3 --- index.ts | 5 ++++- package-lock.json | 13 +++++++++---- package.json | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/index.ts b/index.ts index daaa710..7f3992d 100644 --- a/index.ts +++ b/index.ts @@ -4,6 +4,7 @@ import tmp from "tmp"; import path from "path"; import csstree from "css-tree"; import { Plugin } from "esbuild"; +import slash from "slash"; import { escapeClassName, @@ -125,8 +126,10 @@ export = (options: Options = {}): Plugin => ({ // @ts-ignore await writeFile(tmpFilePath, csstree.generate(ast)); + const importPath = + process.platform == "win32" ? slash(tmpFilePath) : tmpFilePath; let contents = ` - import "${tmpFilePath}"; + import "${importPath}"; const result = ${JSON.stringify(classMap)}; export default result; `; diff --git a/package-lock.json b/package-lock.json index 6eaf041..f9f180d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -924,6 +924,12 @@ "supports-color": "^7.1.0" } }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -1950,10 +1956,9 @@ "integrity": "sha1-5fGrEbXQt3oXHvn/1dk0g9E1bN4=" }, "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==" }, "source-map": { "version": "0.6.1", diff --git a/package.json b/package.json index be3ad94..edae869 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "css-tree": "^1.1.2", "fs-extra": "^9.0.1", "rm": "^0.1.8", + "slash": "^4.0.0", "tmp": "^0.2.1", "typescript": "^4.2.4" },