vite-plugin-components
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -62,2 +62,6 @@ import { Plugin } from 'vite'; | ||
/** | ||
* Apply custom transform over the path for importing | ||
*/ | ||
importPathTransform?: (path: string) => string | undefined; | ||
/** | ||
* Transformer to apply | ||
@@ -64,0 +68,0 @@ * |
@@ -72,3 +72,4 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __assign = Object.assign; | ||
customLoaderMatcher: () => false, | ||
customComponentResolvers: [] | ||
customComponentResolvers: [], | ||
importPathTransform: (v) => v | ||
}; | ||
@@ -123,3 +124,8 @@ | ||
} | ||
function stringifyComponentImport({name, path, importName}) { | ||
function stringifyComponentImport({name, path, importName}, ctx) { | ||
if (ctx.options.importPathTransform) { | ||
const result = ctx.options.importPathTransform(path); | ||
if (result != null) | ||
path = result; | ||
} | ||
if (importName) | ||
@@ -366,3 +372,3 @@ return `import { ${importName} as ${name} } from '${path}'`; | ||
const var_name = `__vite_components_${no}`; | ||
head.push(stringifyComponentImport(__assign(__assign({}, component), {name: var_name}))); | ||
head.push(stringifyComponentImport(__assign(__assign({}, component), {name: var_name}), ctx)); | ||
no += 1; | ||
@@ -403,3 +409,3 @@ return var_name; | ||
const var_name = `__vite_components_${no}`; | ||
head.push(stringifyComponentImport(__assign(__assign({}, component), {name: var_name}))); | ||
head.push(stringifyComponentImport(__assign(__assign({}, component), {name: var_name}), ctx)); | ||
no += 1; | ||
@@ -406,0 +412,0 @@ return `_c(${var_name}${append}`; |
{ | ||
"name": "vite-plugin-components", | ||
"description": "Components auto importing for Vite", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.mjs", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36874
968