Skip to content

Commit 70cc0fb

Browse files
committed
fix: win 下路径问题
1 parent c245777 commit 70cc0fb

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require('path');
2+
const upath = require('upath');
23
const relative = require('relative');
34

45
function MpvuePlugin() {}
@@ -15,9 +16,10 @@ MpvuePlugin.prototype.apply = function(compiler) {
1516
chunks.reverse().forEach(chunk => {
1617
chunk.files.forEach(childFile => {
1718
if (path.extname(childFile) === extname && compilation.assets[filePath]) {
18-
content = extname === '.wxss' ?
19-
`@import "${relative(filePath, childFile)}";\n${content}`
20-
: `require("${relative(filePath, childFile)}");\n${content}`;
19+
const relativePath = upath.normalize(relative(filePath, childFile))
20+
content = extname === '.wxss' ?
21+
`@import "${relativePath}";\n${content}`
22+
: `require("${relativePath}");\n${content}`;
2123
}
2224
})
2325
compilation.assets[filePath].source = () => content;
@@ -28,4 +30,4 @@ MpvuePlugin.prototype.apply = function(compiler) {
2830
});
2931
};
3032

31-
module.exports = MpvuePlugin;
33+
module.exports = MpvuePlugin;

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack-mpvue-asset-plugin",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"main": "index.js",
55
"directories": {
66
"lib": "lib"
@@ -24,6 +24,7 @@
2424
"homepage": "https://github.com/mpvue/webpack-mpvue-asset-plugin#readme",
2525
"description": "",
2626
"dependencies": {
27-
"relative": "^3.0.2"
27+
"relative": "^3.0.2",
28+
"upath": "^1.1.0"
2829
}
2930
}

0 commit comments

Comments
 (0)