vite-plugin-lazy-import
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -19,2 +19,3 @@ (function (global, factory) { | ||
}); | ||
exports.kebabCase = void 0; | ||
exports.lazyImport = lazyImport; | ||
@@ -77,2 +78,3 @@ var _esModuleLexer = require("es-module-lexer"); | ||
} | ||
var kebabCase = exports.kebabCase = _xeUtils["default"].kebabCase; | ||
function lazyImport(options) { | ||
@@ -117,4 +119,4 @@ var opts = Object.assign({ | ||
var extName = resOpts.importStyle === true ? 'css' : resOpts.importStyle || 'css'; | ||
jsPath = "import { ".concat(name, " } from \"").concat(resOpts.lib, "/").concat(libDir, "/").concat(_xeUtils["default"].kebabCase(importName), "/index.js\""); | ||
stylePath = "import \"".concat(resOpts.lib, "/").concat(libDir, "/").concat(_xeUtils["default"].kebabCase(importName), "/style.").concat(extName, "\""); | ||
jsPath = "import { ".concat(name, " } from \"").concat(resOpts.lib, "/").concat(libDir, "/").concat(kebabCase(importName), "/index.js\""); | ||
stylePath = "import \"".concat(resOpts.lib, "/").concat(libDir, "/").concat(kebabCase(importName), "/style.").concat(extName, "\""); | ||
if (resOpts.resolve) { | ||
@@ -121,0 +123,0 @@ var rest = resOpts.resolve({ |
{ | ||
"name": "vite-plugin-lazy-import", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Used for vite Lazy import js and style", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -5,4 +5,68 @@ # vite-plugin-lazy-import | ||
## Installation | ||
```shell | ||
npm install vite-plugin-lazy-import -D | ||
``` | ||
```javascript | ||
// vite.config.ts | ||
import { lazyImport } from 'vite-plugin-lazy-import' | ||
export default defineConfig({ | ||
// ... | ||
plugins: [ | ||
lazyImport({ | ||
resolvers: [ | ||
{ lib: 'vxe-pc-ui', importStyle: 'css', esm: true } | ||
] | ||
}) | ||
] | ||
// ... | ||
}) | ||
``` | ||
## Usage | ||
```javascript | ||
// main.ts | ||
// ... | ||
import { VxeUI, VxeButton } from 'vxe-pc-ui' | ||
//... | ||
VxeUI.setConfig({}) | ||
createApp(App).use(VxeButton).mount('#app') | ||
``` | ||
into this | ||
```javascript | ||
// main.ts | ||
// ... | ||
import { VxeUI } from 'vxe-pc-ui/es/vxe-ui/index.js' | ||
import { VxeButton } from 'vxe-pc-ui/es/vxe-button/index.js' | ||
//... | ||
VxeUI.setConfig({}) | ||
createApp(App).use(VxeButton).mount('#app') | ||
``` | ||
```javascript | ||
lazyImport({ | ||
resolvers: [ | ||
{ | ||
lib: 'vxe-pc-ui', | ||
importStyle: 'css', | ||
resolve ({ name }) { | ||
return | ||
} | ||
} | ||
] | ||
}) | ||
``` | ||
## License | ||
[MIT](LICENSE) © 2019-present, Xu Liangzhan |
import { Plugin, FilterPattern } from 'vite' | ||
import { kebabCase as kebabCaseMethod } from 'xe-utils' | ||
@@ -25,2 +26,4 @@ export interface LazyImportResolverResult { | ||
export const kebabCase = kebabCaseMethod | ||
export function lazyImport (options: LazyImportConfig): Plugin<any> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21461
449
72