forked from SortableJS/vue.draggable.next
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding configuration to filter route in dev
- Loading branch information
1 parent
3633756
commit 5cf3385
Showing
10 changed files
with
66 additions
and
27 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VUE_APP_SHOW_ALL_EXAMPLES=false | ||
VUE_APP_FILTER_ROUTE= |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
VUE_APP_SHOW_ALL_EXAMPLES=false | ||
VUE_APP_FILTER_ROUTE= |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ test/tmp | |
/examples/src | ||
/examples/libs/ | ||
/coverage | ||
|
||
.env.local |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,63 @@ | ||
function getRouteFromDirectory(ctx) { | ||
return ctx.keys().map(key => ({ | ||
path: key.substring(1).replace(".vue", ""), | ||
component: ctx(key).default, | ||
component: ctx(key).default | ||
})); | ||
} | ||
|
||
const showAll = process.env.VUE_APP_SHOW_ALL_EXAMPLES === "true"; | ||
window.console.log(process.env.VUE_APP_SHOW_ALL_EXAMPLES); | ||
const showDebug = process.env.VUE_APP_SHOW_ALL_EXAMPLES === "true"; | ||
window.console.log(showDebug); | ||
|
||
function getRouteFilterFromConfiguration(configuration) { | ||
const routeFromConfiguration = configuration | ||
.split(",") | ||
.filter(value => value !== ""); | ||
if (routeFromConfiguration == []) { | ||
return () => true; | ||
} | ||
|
||
window.console.log( | ||
`Using route filter VUE_APP_FILTER_ROUTE: "${configuration}"` | ||
); | ||
return name => routeFromConfiguration.includes(name); | ||
} | ||
|
||
const filterRoute = getRouteFilterFromConfiguration( | ||
process.env.VUE_APP_FILTER_ROUTE | ||
); | ||
|
||
const routes = [ | ||
...getRouteFromDirectory(require.context("./components/", false, /\.vue$/)), | ||
...(!showAll | ||
...(!showDebug | ||
? [] | ||
: getRouteFromDirectory( | ||
require.context("./debug-components/", false, /\.vue$/) | ||
)), | ||
{ | ||
path: "/", | ||
redirect: "/simple", | ||
}, | ||
)) | ||
]; | ||
routes.forEach( | ||
route => (route.component.show = filterRoute(route.component.display)) | ||
); | ||
|
||
window.console.log(routes); | ||
const filteredRoutes = routes.filter(route => route.component.show); | ||
|
||
if (filteredRoutes.length === 0) { | ||
throw new Error( | ||
`No routes to match "${ | ||
process.env.VUE_APP_FILTER_ROUTE | ||
}". Available route: ${routes | ||
.map(route => `"${route.component.display}"`) | ||
.join(", ")} .Please check env variable: VUE_APP_FILTER_ROUTE` | ||
); | ||
} | ||
|
||
const redirect = filteredRoutes.some(r => r.path === "/simple") | ||
? "/simple" | ||
: filteredRoutes[0].path; | ||
|
||
const allRoutes = [ | ||
...filteredRoutes, | ||
{ path: "/", redirect }, | ||
{ path: "/:pathMatch(.*)*", redirect } | ||
]; | ||
|
||
export default routes; | ||
export default allRoutes; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,7 @@ const tags = [ | |
"ul", | ||
"var", | ||
"video", | ||
"wbr", | ||
"wbr" | ||
]; | ||
|
||
function isHtmlTag(name) { | ||
|