
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
vite-plugin-parse-html
Advanced tools
just parse html for your inject some script or css, more then inject some data
Insert variables into the host page through the ejs template engine;
Through configuration items, some dynamically inserted javascript and css files are usually used to coordinate with the project externals
Indexhtml compression
support multi page applications
yarn add vite-plugin-parse-html -D
npm i vite-plugin-parse-html -D
1、Use the inject
and minify
configuration item in vite.config.ts
to configure
...
import { inject, minify } from 'vite-plugin-parse-html'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
inject({
data: {
title: 'test project',
},
sources: [
'http://xxxx.css',
'http://xxxx.js',
{ type: 'javascript', url: 'http://yyyy'},
],
}),
minify({
isMinify: true,
}),
react(),
],
})
2、Using plugins in multi page programs
...
import { inject, minify } from 'vite-plugin-parse-html'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
inject([
{
path: '/index.html',
data: {
title: 'test project',
},
sources: [
'http://xxxx.css',
'http://xxxx.js',
{ type: 'javascript', url: 'http://yyyy'},
],
},
{
path:'/nest/index.html'
data: {
title: 'test project',
},
sources: [
'http://xxxx.css',
'http://xxxx.js',
{ type: 'javascript', url: 'http://yyyy'},
],
}
]),
minify({
isMinify: true,
}),
...
],
})
parameter | type | default | example | description |
---|---|---|---|---|
path | string | '/index.html' | '/nest/index.html' | multiple page relative path |
data | Record<string, any> | {} | {title: 'xxxx'} | Variables used on the host page |
ejsOptions | Options | |||
sources | Array<SourceItem | string> | {} | [ 'http://xxx.js' ] or [{ url: 'http:xxx.js', type: 'javascript', position: 'head' }] |
parameter | type | default | example | description |
---|---|---|---|---|
type | 'css' or 'javascript' | 'css' | type: 'css' | source type |
url | string | url: 'http://xxxxx' | source cdn url | |
position | 'head' 'body' 'head-prepend' 'body-prepend' | 'head' | position: 'head' | inject to html position |
attrs | Record<string, any> | { async: '' } | tags attributes and value |
parameter | type | default | example | description |
---|---|---|---|---|
isMinify | boolean | true | isMinify: true | Whether to compress the host page |
FAQs
just parse html for your inject some script or css, more then inject some data
The npm package vite-plugin-parse-html receives a total of 243 weekly downloads. As such, vite-plugin-parse-html popularity was classified as not popular.
We found that vite-plugin-parse-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
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.