Skip to content

Commit 3c7114b

Browse files
Correctly setup the path for the import statement of the ES module where it is being imported. (#9)
1 parent 3a7786f commit 3c7114b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ module.exports = function (options = {}) {
4747
const data = fs.readFileSync(filePath, {
4848
encoding: 'utf8',
4949
});
50-
fs.writeFileSync(filePath, `import './${cssFile}';\n${data}`);
50+
51+
const filePathDepth = file.split('/').length - 1;
52+
const relativePath = Array(filePathDepth).fill('../').join('');
53+
fs.writeFileSync(filePath, `import './${relativePath}${cssFile}';\n${data}`);
5154
}
5255
},
5356
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vite-plugin-libcss",
33
"description": "This plugin will inject css into bundled js file using `import` statement.",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"main": "index.js",
66
"types": "index.d.ts",
77
"author": "wxsms@foxmail.com",

0 commit comments

Comments
 (0)