Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-lazy-import

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-lazy-import

Used for vite Lazy import js and style

  • 1.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
239
decreased by-14.95%
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-lazy-import

Used for vite Lazy import js and style.

Installation

npm install vite-plugin-lazy-import -D
// vite.config.ts
import { lazyImport } from 'vite-plugin-lazy-import'

export default defineConfig({
  // ...
  plugins: [
    lazyImport({
      resolvers: [
        {
          lib: 'vxe-pc-ui',
          importStyle: 'css', // import style '*.css'
          esm: true // import directory '/es/*' | '/lib/*'
        }
      ]
    })
  ]
  // ...
})

Usage

// main.ts
// ...
import { VxeUI, VxeButton } from 'vxe-pc-ui'
//...

VxeUI.setConfig({})

createApp(App).use(VxeButton).mount('#app')

into this

// 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')

Lazy import js

import { lazyImport } from 'vite-plugin-lazy-import'

lazyImport({
  resolvers: [
    {
      lib: 'vxe-pc-ui',
      resolve ({ name, dirName }) {
        return {
          from: `vxe-pc-ui/es/${dirName}/index.js`
        }
      }
    }
  ]
})

Lazy import js and css

import { lazyImport } from 'vite-plugin-lazy-import'

lazyImport({
  resolvers: [
    {
      lib: 'vxe-pc-ui',
      importStyle: true,
      resolve ({ name, dirName }) {
        return {
          from: {
            jsPath: `vxe-pc-ui/es/${dirName}/index.js`,
            stylePath: `vxe-pc-ui/es/${dirName}/style.css`
          }
        }
      }
    }
  ]
})

License

MIT © 2019-present, Xu Liangzhan

Keywords

FAQs

Package last updated on 11 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc