Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

feat: 将css引用的图片转换成相对根路径 #198

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/remax-cli/src/build/plugins/postcssUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RemaxOptions } from '../../getConfig';

interface Asset {
url: string;
absolutePath: string;
}

export default (options: RemaxOptions) =>
Expand All @@ -25,6 +26,12 @@ export default (options: RemaxOptions) =>
});
}
});
if (!/^\//.test(asset.url)) {
Darmody marked this conversation as resolved.
Show resolved Hide resolved
return `/${path.relative(
path.resolve(options.cwd, 'src'),
asset.absolutePath
)}`;
}
return asset.url;
},
basePath: path.resolve(options.cwd, 'src'),
Expand Down