Socket
Socket
Sign inDemoInstall

vite-plugin-vue-transform-import

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vite-plugin-vue-transform-import

一个在打包阶段把import函数转换为import命令的vite插件


Version published
Maintainers
1
Install size
2.98 kB
Created

Readme

Source

transform-import

一个在打包阶段把 import 函数转换为 import 命令的 vite 插件

该插件会把当前文件所有通过import函数方式引入改为通过import命令方式引入。

转换前

路径请以@开头以.vue文件结尾,别名@可在vite.config.js文件中配置

const index = () => import('@/pages/index.vue')

const tab = () => import('@/pages/tab.vue')

转换后

import index from '@/pages/index.vue'

import tab from '@/pages/tab.vue'

安装

npm install vite-plugin-vue-transform-import --save-dev

使用

// vite.config.js

import transformImport from 'vite-plugin-vue-transform-import'

export default {
    alias: { '@': path.resolve(__dirname, 'src') },
    plugins: [
        // 传入需要转换文件的相对路径路径
        transformImport('/router/index.js')
    ]
}

Keywords

FAQs

Last updated on 11 Jul 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc