
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
vite-plugin-inject-html
Advanced tools
- [`favicon`](#favicon) - favicon url - [`title`](#title) - title - [`metas`](#metas) - `<meta>` tags - [`links`](#links) - `<link>` tags - [`externalStyleSheets`](#externalStyleSheets) - external style sheet urls - [`scripts`](#scripts) - `<script>`
favicon
- favicon urltitle
- titlemetas
- <meta>
tagslinks
- <link>
tagsexternalStyleSheets
- external style sheet urlsscripts
- <script>
tagsnoscripts
- <noscript>
tagsotherTags
- other tags// vite.config.ts
import { defineConfig } from 'vite'
import injectHTMLPlugin from 'vite-plugin-inject-html'
export default defineConfig({
plugins: [
injectHTMLPlugin({
favicon: 'https://example.com/favicon.ico'
})
]
})
<!-- index.html -->
<head>
<link rel="icon" href="https://example.com/favicon.ico" />
</head>
<title>
tag// vite.config.ts
import { defineConfig } from 'vite'
import injectHTMLPlugin from 'vite-plugin-inject-html'
export default defineConfig({
plugins: [
injectHTMLPlugin({
title: 'My App'
})
]
})
<!-- index.html -->
<head>
<title>My App</title>
</head>
// vite.config.ts
import { defineConfig } from 'vite'
import injectHTMLPlugin from 'vite-plugin-inject-html'
export default defineConfig({
plugins: [
injectHTMLPlugin({
metas: [
{
name: 'description',
content: 'My App'
}
]
})
]
})
<!-- index.html -->
<head>
<meta name="description" content="My App" />
</head>
// vite.config.ts
import { defineConfig } from 'vite'
import injectHTMLPlugin from 'vite-plugin-inject-html'
export default defineConfig({
plugins: [
injectHTMLPlugin({
links: [
{
rel: 'stylesheet',
href: 'https://example.com/style.css'
}
]
})
]
})
<!-- index.html -->
<head>
<link rel="stylesheet" href="https://example.com/style.css" />
</head
// vite.config.ts
import { defineConfig } from 'vite'
import injectHTMLPlugin from 'vite-plugin-inject-html'
export default defineConfig({
plugins: [
injectHTMLPlugin({
externalStyleSheets: [
'https://example.com/style.css',
'https://example.com/style2.css'
]
})
]
})
<!-- index.html -->
<head>
<link rel="stylesheet" type="text/css" href="https://example.com/style.css" />
<link rel="stylesheet" type="text/css" href="https://example.com/style2.css" />
</head
injectTo
can be head-prepend
, head
, body-prepend
or body
, default to body
// vite.config.ts
import { defineConfig } from 'vite'
import injectHTMLPlugin from 'vite-plugin-inject-html'
export default defineConfig({
plugins: [
injectHTMLPlugin({
scripts: [
`console.log('String Content 1')`,
{
children: `console.log('String Content 2')`,
injectTo: 'head-prepend'
},
{
src: 'https://example.com/script.js',
attributes: { async: true },
injectTo: 'body-prepend'
}
]
})
]
})
<!-- index.html -->
<head>
<script>
console.log('String Content 2')
</script>
</head>
<body>
<script src="https://example.com/script.js"></script>
<script>
console.log('String Content 1')
</script>
</body>
injectTo
can be head-prepend
, head
, body-prepend
or body
, default to body
// vite.config.ts
import { defineConfig } from 'vite'
import injectHTMLPlugin from 'vite-plugin-inject-html'
export default defineConfig({
plugins: [
injectHTMLPlugin({
noscripts: [
`console.log('String Content 1')`,
{
children: `console.log('String Content 2')`,
injectTo: 'body-prepend'
}
]
})
]
})
<!-- index.html -->
<body>
<noscript>
console.log('String Content 2')
</noscript>
<noscript>
console.log('String Content 1')
</noscript>
</body>
injectTo
can be head-prepend
, head
, body-prepend
or body
, default to head-prepend
// vite.config.ts
import { defineConfig } from 'vite'
import injectHTMLPlugin from 'vite-plugin-inject-html'
export default defineConfig({
plugins: [
injectHTMLPlugin({
otherTags: [
{
tagName: 'h1',
attrs: { id: 'title' },
children: 'Hello World',
injectTo: 'body'
}
]
})
]
})
<!-- index.html -->
<body>
<h1 id="title">Hello World</h1>
</body>
FAQs
[](https://npmjs.com/package/vite-plugin-inject-html) [](https://nodejs.org/en/about/releases)
The npm package vite-plugin-inject-html receives a total of 13 weekly downloads. As such, vite-plugin-inject-html popularity was classified as not popular.
We found that vite-plugin-inject-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.