Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
vite-plugin-raw-assets
Advanced tools
Vite plugin to load assets as strings.
Usefull to deal with third-party libraries that expect to import assets as strings but doesn't add ?raw
to import URL.
It's similar to raw-loader in Webpack.
Suppose we have a library called some-lib
with the following import:
import refreshSvgstr from './style/icons/refresh.svg';
The library expect refreshSvgstr
to be a string but vite will assign the asset URL.
This plugin helps to deal with this situation.
This plugin requires an LTS Node version (v16.0.0+) and Vite v3.0.0+.
npm i vite-plugin-raw-assets -D
vite.config.ts
import rawAssets from 'vite-plugin-raw-assets';
export default {
plugins: [
rawAssets({
include: '**/some-lib/**/*.svg'
}),
],
}
This plugin only work on assets. It uses assetsInclude to decide if a file is an asset or not.
rawAssets(config: Configuration)
export interface Configuration {
/**
* Options passed to @rollup/pluginutils's createFilter.
* The plugin only load files that pass the created filter.
*
* See https://github.com/rollup/plugins/tree/master/packages/pluginutils#include-and-exclude
*/
include?: String | RegExp | Array[...String|RegExp]
exclude?: String | RegExp | Array[...String|RegExp]
}
FAQs
Vite plugin to load assets as strings
We found that vite-plugin-raw-assets demonstrated a healthy version release cadence and project activity because the last version was released less than 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.