vite-plugin-lazy-import
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -121,3 +121,4 @@ (function (global, factory) { | ||
var rest = resOpts.resolve({ | ||
name: importName | ||
name: importName, | ||
lib: resOpts.lib | ||
}); | ||
@@ -127,9 +128,9 @@ var fromRest = rest ? rest.from : null; | ||
if (_xeUtils["default"].isString(fromRest)) { | ||
jsPath = fromRest; | ||
jsPath = "import { ".concat(name, " } from \"").concat(fromRest, "\""); | ||
} else { | ||
if (fromRest.jsPath) { | ||
jsPath = fromRest.jsPath; | ||
jsPath = "import { ".concat(name, " } from \"").concat(fromRest.jsPath, "\""); | ||
} | ||
if (fromRest.stylePath) { | ||
stylePath = fromRest.stylePath; | ||
stylePath = "import \"".concat(fromRest.stylePath, "\""); | ||
} | ||
@@ -162,5 +163,3 @@ } | ||
opts.resolvers.forEach(function (resolver) { | ||
var resOpts = Object.assign({ | ||
esm: true | ||
}, resolver); | ||
var resOpts = Object.assign({}, resolver); | ||
if (!resOpts.lib) { | ||
@@ -167,0 +166,0 @@ return; |
{ | ||
"name": "vite-plugin-lazy-import", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Used for vite Lazy import js and style", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -20,3 +20,7 @@ # vite-plugin-lazy-import | ||
resolvers: [ | ||
{ lib: 'vxe-pc-ui', importStyle: 'css', esm: true } | ||
{ | ||
lib: 'vxe-pc-ui', | ||
importStyle: 'css', // import style '*.css' | ||
esm: true // import directory '/es/*' | '/lib/*' | ||
} | ||
] | ||
@@ -56,3 +60,7 @@ }) | ||
## Lazy import js | ||
```javascript | ||
import { lazyImport, kebabCase } from 'vite-plugin-lazy-import' | ||
lazyImport({ | ||
@@ -62,5 +70,6 @@ resolvers: [ | ||
lib: 'vxe-pc-ui', | ||
importStyle: 'css', | ||
resolve ({ name }) { | ||
return | ||
return { | ||
from: `vxe-pc-ui/es/${kebabCase(name)}/index.js` | ||
} | ||
} | ||
@@ -72,4 +81,27 @@ } | ||
## Lazy import js and css | ||
```javascript | ||
import { lazyImport, kebabCase } from 'vite-plugin-lazy-import' | ||
lazyImport({ | ||
resolvers: [ | ||
{ | ||
lib: 'vxe-pc-ui', | ||
importStyle: true, | ||
resolve ({ name }) { | ||
return { | ||
from: { | ||
jsPath: `vxe-pc-ui/es/${kebabCase(name)}/index.js` | ||
stylePath: `vxe-pc-ui/es/${kebabCase(name)}/style.css` | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}) | ||
``` | ||
## License | ||
[MIT](LICENSE) © 2019-present, Xu Liangzhan |
@@ -17,2 +17,3 @@ import { Plugin, FilterPattern } from 'vite' | ||
name: string | ||
lib: string | ||
}) => null | LazyImportResolverResult | ||
@@ -19,0 +20,0 @@ } |
Sorry, the diff of this file is not supported yet
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
22503
104
447