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

fwafwa

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

fwafwa

During the development process, there are a small number of special cases where the path substitution of Vite's native alis is not enough to meet the development needs.So this is again an enhanced version of the foundation, and the plugin is compatible wi

  • 1.0.2
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

vite alias Enhanced version

During the development process, there are a small number of special cases where the path substitution of Vite's native alis is not enough to meet the development needs.So this is again an enhanced version of the foundation, and the plugin is compatible with Vite's native alias

Download address

npm i vite-plugin-alias2

Plugin usage

The plugin supports vue ts tsx js css scss less json ... files The plugin accepts two parameter formats

export interface Alias {
  find: string | RegExp;
  replacement: string;
}

export interface ViteAliasOptions {
  entries?: { [find: string]: string } | Alias[];
}

vite.config.ts


import Alias from 'vite-plugin-alias'
// Array form
plugins: [Alias({
    entries: [
      { find: '~', replacement: 'src' },  
      { find: '~/style.css', replacement: './style.css' }, 
      { find: "^@vue/(.*?)$", replacement: 'src/$1/src' }, 
      { find: /^(.*)\.js$/, replacement: '$1.wasm' }, 
    ],
  })],

// Object shorthand is supported
plugins: [Alias({
    entries: {
      '~': '.',
      '~/style.css': './style.css',
      "^@vue/(.*?)$": 'src/$1/src',
    }
  })],


The case is as follows

<template>
  <div></div>
</template>

<script setup lang="ts">
import "@vue/shared";
import "~/da";
import "index.js";
import * as m from "index.js";
import { a } from "./index";
</script>

<style lang="scss" scoped>
@import "~/style.css";
</style>

After compilation, the code wrapped in conditional comments will replace the path

<template>
  <div></div>
</template>

<script setup lang="ts">
import "src/shared/src";
import "./da";
import "index.wasm";
import * as m from "index.wasm";
import { a } from "./index";
</script>

<style lang="scss" scoped>
@import "./style.css";
</style>
"

Keywords

FAQs

Package last updated on 05 Mar 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