
Security News
GitHub Actions Supply Chain Attack Puts Thousands of Projects at Risk
A compromised GitHub Action exposed secrets in CI/CD logs, putting thousands of projects at risk and forcing developers to urgently secure their workflows.
vite-plugin-plain-text
Advanced tools
A Vite plugin transforms the rule-matched file as plain text.
A Vite plugin that transforms matched files into plain text.
pnpm i -D vite-plugin-plain-text (or npm/yarn)
Assume we are going to transform these files:
LICENSE
file.glsl
fileinto plain text.
// vite.config.(t|j)s
import { defineConfig } from 'vite';
import plainText from 'vite-plugin-plain-text';
export default defineConfig({
plugins: [
// passing regular expression or glob matcher
plainText([/\/LICENSE$/, '**/*.text', /\.glsl$/]),
],
});
// component.js
import { plainText as LICENSE } from '../LICENSE'
import { plainText as Lorem } from '../lorem-ipsum.text'
import { plainText as Siren } from '../siren.glsl'
console.log(LICENSE)
console.log(Lorem)
console.log(Siren)
type PlainTextOptions = {
namedExport?: string | false,
dtsAutoGen?: boolean,
distAutoClean?: boolean,
}
Use the plainTextOptions.namedExport
option to configure the named exported variable. To enable the default export, pass false
, ''
, or undefined
.
// vite.config.(t|j)s
import { defineConfig } from 'vite';
import plainText from 'vite-plugin-plain-text';
export default defineConfig({
plugins: [
plainText(
[/\/LICENSE$/, '**/*.text', /\.glsl$/],
{ namedExport: false },
),
],
});
// component.js
import LICENSE from '../LICENSE'
import Lorem from '../lorem-ipsum.text'
import Siren from '../siren.glsl'
console.log(LICENSE)
console.log(Lorem)
console.log(Siren)
// vite-env.d.ts
declare module '*/LICENSE' {
export const plainText: string
}
declare module '*.text' {
export const plainText: string
}
declare module '*.glsl' {
export const plainText: string
}
plainTextOptions.dtsAutoGen
generates .dts
files for matched files.plainTextOptions.dtsAutoClean
cleans up these .dts
files after the vite plugin starts up each time.import { defineConfig } from 'vite';
import plainText from 'vite-plugin-plain-text';
export default defineConfig({
plugins: [
plainText(
[/\/LICENSE$/, '**/*.text', /\.glsl$/],
{ namedExport: false, dtsAutoGen: true, distAutoClean: true },
),
],
});
MIT
Virtual asset Loader: vite-plugin-virtual-plain-text
FAQs
A Vite plugin transforms the rule-matched file as plain text.
The npm package vite-plugin-plain-text receives a total of 4,143 weekly downloads. As such, vite-plugin-plain-text popularity was classified as popular.
We found that vite-plugin-plain-text 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
A compromised GitHub Action exposed secrets in CI/CD logs, putting thousands of projects at risk and forcing developers to urgently secure their workflows.
Research
Security News
A malicious Maven package typosquatting a popular library is secretly stealing OAuth credentials on the 15th of each month, putting Java developers at risk.
Security News
Socket and Seal Security collaborate to fix a critical npm overrides bug, resolving a three-year security issue in the JavaScript ecosystem's most popular package manager.