- place script into root component folder (
components
). - run script
- use import with object deconstruct (
import { MyAwesomeComponent } from "@/components"
) - enjoy 🐱👤
Created
October 6, 2021 12:20
-
-
Save PadreSVK/e67e9855b38da8cc5d94c0c86b833760 to your computer and use it in GitHub Desktop.
Vue component "index" generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$components = New-Object 'System.Collections.Generic.List[System.String]' | |
ls $PSScriptRoot -Filter *.vue -Recurse | % { | |
$relativePathToComponent = $_.FullName.Replace($PSScriptRoot, "" ).Replace("\" , "/") | |
$componentPath = "@/components$relativePathToComponent" | |
$componentName = $([System.IO.Path]::GetFileNameWithoutExtension($_.Name)) | |
$components.Add("export { default as $componentName} from `"$componentPath`"") | |
} | |
Set-Content -Path "$PSScriptRoot/index.ts" -Value $components |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment