fix(cli): failed to import sfc after build

This commit is contained in:
chenjiahan
2020-12-03 16:21:59 +08:00
parent 764e9e2d69
commit ac856c2673
4 changed files with 20 additions and 8 deletions
@@ -71,3 +71,15 @@ export function getDeps(filePath: string) {
return paths;
}
// "import App from 'App.vue';" => "import App from 'App.xxx';"
export function replaceScriptImportExt(code: string, from: string, to: string) {
const importLines = matchImports(code);
importLines.forEach(importLine => {
const result = importLine.replace(from, to);
code = code.replace(importLine, result);
});
return code;
}