Skip to content

Commit

Permalink
Fixes Does not work on Windows koluch#3
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLonelyAdventurer committed Jul 7, 2021
1 parent 1f97e22 commit aa777d3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
`;
Expand Down
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit aa777d3

Please sign in to comment.