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

vite-plugin-dev-external

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-dev-external

开发过程中排除特定依赖项.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

Vite插件: 外部化依赖项

开发过程中排除特定依赖项. 可以和build.rollupOptions.external很好的配合使用.

ps: 这只是一个补丁. 本插件破坏了插件的加载顺序.

该项目灵感来源于: MilanKovacic/vite-plugin-externalize-dependencies

Installation

npm i -D vite-plugin-dev-external

Usage

安装插件后,导入它,并将其添加到 Vite 配置中:

例如你使用了socket.io并开启了socket.ioserveClient选项:

import { defineConfig } from 'vite';
import externalize from 'vite-plugin-dev-external';

export default defineConfig({
    build: {
        rollupOptions: {
            external: ['/socket.io/socket.io.esm.min.js'],
        },
    },
    plugins: [externalize()],
});

或者你只需要在开发中使用它:

import { defineConfig } from 'vite';
import externalize from 'vite-plugin-dev-external';

export default defineConfig({
    plugins: [externalize({
        external: [
            'externalized-dependency',
            '/absolute/path/externalized-dependency',
        ],
    })],
});

本插件也能和resolve.alias选项很好配合:

import { defineConfig } from 'vite';
import externalize from 'vite-plugin-dev-external';

export default defineConfig({
    build: {
        rollupOptions: {
            external: ['/socket.io/socket.io.esm.min.js'],
        },
    },
    resolve: {
        alias: {
            'socket.io': '/socket.io/socket.io.esm.min.js',
        },
    },
    plugins: [externalize()],
});

Requirements

The plugin is intended to be consumed by Vite.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 22 Aug 2023

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