New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

vite-plugin-html-insert

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-html-insert

insert env variables in html file

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

vite-plugin-html-insert

insert env variables in html file

install

npm

npm install --save-dev vite-plugin-html-insert

yarn

yarn add -D vite-plugin-html-insert

pnpm

pnpm install -D vite-plugin-html-insert

usage

visit examplte config

1. inject variables from .env

vite.config.js

import insertContentHtmlPlugin from 'vite-plugin-html-insert';

export default {
    plugins: [
        insertContentHtmlPlugin()
    ]
}

.env file

VITE_TITLE=awesome

index.html

<title> %VITE_TITLE% </title>

2. inject varibales from custom data

vite.config.js

import insertContentHtmlPlugin from 'vite-plugin-html-insert';

export default {
    plugins: [
        insertContentHtmlPlugin({
            replacements: {
                CDN_URL: 'https://cdn.me.com'
            }
        })
    ]
}

index.html

<script>
var CDN_URL = '%CDN_URL%';
</script>

3. inject content by custom transform

vite.config.js

import insertContentHtmlPlugin from 'vite-plugin-html-insert';

export default {
    plugins: [
        insertContentHtmlPlugin({
            transform: (content) => {
                content = content.replace(/%VERSION%/, '2.0.1');
                return content;
            }
        })
    ]
}

index.html

<script>
var VERSION = '%VERSION%';
</script>

Keywords

vue

FAQs

Package last updated on 16 Jan 2022

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