Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@lightningtv/vite-hex-transform
Advanced tools
The hexColorTransform
plugin for Vite transforms "#RRGGBB"
, "#RGB"
, "#RRGGBBAA"
, and "#RGBA"
into 0xRRGGBBAA
format and handling optional alpha values correctly. This documentation provides instructions for configuring the plugin with include and exclude filters.
If you were using hexColor, you can find and replace all instances with:
Use VSCode to remove hexColor
hexColor\("(#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})"\)
"$1"
Additionally, Enable default color decorators
in VScode in your settings (Command + , to search for the setting) to get built in color highlighting
npm i @lightningtv/vite-hex-transform -D
Create or update the vite.config.js
file in your Vite project to include the hexColorTransform
plugin with options for including and excluding files.
// vite.config.js
import { defineConfig } from 'vite';
import hexColorTransform from './hexColorTransform';
export default defineConfig({
plugins: [
hexColorTransform({
include: '**/*.js', // Include all JavaScript files
exclude: 'node_modules/**', // Exclude files in node_modules directory
}), // Register your custom plugin with options
],
});
The hexColorTransform
plugin accepts an options object with the following properties:
include
: A glob pattern or an array of glob patterns specifying which files to include. The default is to include all files.exclude
: A glob pattern or an array of glob patterns specifying which files to exclude. The default is to exclude no files.Here are some examples of how to use the include
and exclude
options:
// vite.config.js
import { defineConfig } from 'vite';
import hexColorTransform from './hexColorTransform';
export default defineConfig({
plugins: [
// Include all JavaScript files and exclude files in node_modules directory
hexColorTransform({
include: '**/*.js',
exclude: 'node_modules/**',
}),
// Include only specific files
hexColorTransform({
include: ['src/**/*.js', 'src/**/*.ts'], // Include JavaScript and TypeScript files in the src directory
exclude: 'src/ignore-this-directory/**', // Exclude a specific directory
}),
],
});
const color = "#f6f6f6";
const shortColor = '#fff';
const alphaColor = "#f6f6f680";
const color = 0xF6F6F6FF;
const shortColor = 0xFFFFFFFF;
const alphaColor = 0xF6F6F680;
The hexColorTransform
plugin for Vite provides a convenient way to transform hex color strings in your code. By configuring include and exclude patterns, you can control which files are processed by the plugin, making it flexible and easy to use in various project setups.
For more information and advanced configuration options, refer to the official Vite documentation and the plugin source code.
FAQs
Converts hex colors to 0xRRGGBBAA format
The npm package @lightningtv/vite-hex-transform receives a total of 83 weekly downloads. As such, @lightningtv/vite-hex-transform popularity was classified as not popular.
We found that @lightningtv/vite-hex-transform demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.