
Security News
Feross on TBPN: Socket's Series C and the State of Software Supply Chain Security
Feross Aboukhadijeh joins TBPN to discuss Socket's $60M Series C, 500%+ ARR growth, AI's impact on open source, and the rise in supply chain attacks.
@yaseratiar/react-responsive-easy-vite-plugin
Advanced tools
Vite plugin for React Responsive Easy integration
Enterprise-grade Vite plugin for React Responsive Easy integration and optimization
@yaseratiar/react-responsive-easy-vite-plugin is a high-performance Vite plugin that seamlessly integrates React Responsive Easy into your Vite-based development workflow, providing build-time optimizations and enhanced development experience.
Built for enterprise applications, it offers:
npm install --save-dev @yaseratiar/react-responsive-easy-vite-plugin
yarn add --dev @yaseratiar/react-responsive-easy-vite-plugin
pnpm add --save-dev @yaseratiar/react-responsive-easy-vite-plugin
npm install --save-dev vite @vitejs/plugin-react
npm install --save-dev @yaseratiar/react-responsive-easy-vite-plugin
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
precompute: true,
generateCustomProperties: true
})
]
});
import { useResponsiveValue } from '@yaseratiar/react-responsive-easy-core';
const Hero = () => {
const fontSize = useResponsiveValue(48, { token: 'fontSize' });
const padding = useResponsiveValue(32, { token: 'spacing' });
return (
<h1 style={{ fontSize, padding }}>
Responsive Hero Title
</h1>
);
};
npm run dev
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy()
]
});
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
// Core options
enabled: true,
configPath: './responsive.config.js',
// Configuration options
configInline: {
base: { width: 1920, height: 1080 },
breakpoints: [
{ name: 'mobile', width: 390, height: 844 },
{ name: 'tablet', width: 768, height: 1024 },
{ name: 'desktop', width: 1920, height: 1080 }
],
strategy: {
origin: 'width',
tokens: {
fontSize: { scale: 0.85, min: 12, max: 72 },
spacing: { scale: 0.9, step: 4, min: 4, max: 128 },
radius: { scale: 0.95, min: 2, max: 32 }
}
}
},
// Build options
precompute: true,
generateCustomProperties: true,
generateSourceMaps: true,
// Performance options
enableCaching: true,
cacheSize: 1000,
enableOptimization: true,
// Development options
addComments: process.env.NODE_ENV === 'development',
validateConfig: true,
performanceMetrics: process.env.NODE_ENV === 'development',
// Hooks
onTransform: (module, context) => {
console.log(`Transformed: ${context.filename}`);
},
onError: (error, context) => {
console.error(`Transform error: ${error.message}`);
}
})
]
});
Create a responsive.config.js file:
// responsive.config.js
module.exports = {
base: { width: 1920, height: 1080 },
breakpoints: [
{ name: 'xs', width: 320, height: 568 },
{ name: 'sm', width: 576, height: 667 },
{ name: 'md', width: 768, height: 1024 },
{ name: 'lg', width: 992, height: 1200 },
{ name: 'xl', width: 1200, height: 1600 },
{ name: 'xxl', width: 1920, height: 1080 }
],
strategy: {
origin: 'width',
tokens: {
fontSize: {
scale: 0.85,
min: 12,
max: 72,
step: 1,
round: true
},
spacing: {
scale: 0.9,
step: 4,
min: 4,
max: 128,
round: true
},
radius: {
scale: 0.95,
min: 2,
max: 32,
step: 2,
round: true
}
}
}
};
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
const isDevelopment = process.env.NODE_ENV === 'development';
const isProduction = process.env.NODE_ENV === 'production';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
enabled: true,
// Development optimizations
...(isDevelopment && {
addComments: true,
validateConfig: true,
performanceMetrics: true,
generateSourceMaps: true
}),
// Production optimizations
...(isProduction && {
precompute: true,
enableOptimization: true,
enableCaching: true,
performanceMetrics: false
})
})
]
});
// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
precompute: true,
generateCustomProperties: true
})
],
// TypeScript configuration
esbuild: {
jsx: 'automatic'
},
// Build configuration
build: {
target: 'es2015',
sourcemap: true,
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom'],
responsive: ['@yaseratiar/react-responsive-easy-core']
}
}
}
}
});
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable/disable the plugin |
configPath | string | undefined | Path to configuration file |
configInline | object | undefined | Inline configuration object |
| Option | Type | Default | Description |
|---|---|---|---|
precompute | boolean | true | Enable build-time pre-computation |
generateCustomProperties | boolean | true | Generate CSS custom properties |
generateSourceMaps | boolean | true | Generate source maps |
| Option | Type | Default | Description |
|---|---|---|---|
enableCaching | boolean | true | Enable value caching |
cacheSize | number | 1000 | Maximum cache size |
enableOptimization | boolean | true | Enable build optimization |
| Option | Type | Default | Description |
|---|---|---|---|
addComments | boolean | false | Add helpful comments |
validateConfig | boolean | false | Validate configuration |
performanceMetrics | boolean | false | Collect performance metrics |
| Option | Type | Description |
|---|---|---|
onTransform | function | Called after each transformation |
onError | function | Called when errors occur |
interface PluginOptions {
// Core options
enabled?: boolean;
configPath?: string;
configInline?: ResponsiveConfig;
// Build options
precompute?: boolean;
generateCustomProperties?: boolean;
generateSourceMaps?: boolean;
// Performance options
enableCaching?: boolean;
cacheSize?: number;
enableOptimization?: boolean;
// Development options
addComments?: boolean;
validateConfig?: boolean;
performanceMetrics?: boolean;
// Hooks
onTransform?: (module: Module, context: TransformContext) => void;
onError?: (error: Error, context: TransformContext) => void;
}
interface ResponsiveConfig {
base: Viewport;
breakpoints: Breakpoint[];
strategy: ScalingStrategy;
}
interface Viewport {
width: number;
height: number;
}
interface Breakpoint {
name: string;
width: number;
height: number;
}
interface ScalingStrategy {
origin: 'width' | 'height' | 'area' | 'diagonal';
tokens: TokenConfig;
fallback?: string;
}
interface TokenConfig {
[key: string]: {
scale: number | ((value: number, ratio: number) => number);
min?: number;
max?: number;
step?: number;
round?: boolean;
unit?: string;
};
}
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
precompute: true,
development: true,
// Custom transformation hooks
onTransform: (module, context) => {
// Log all transformations
console.log(`Transformed ${context.filename}:${context.line}:${context.column}`);
// Custom transformation logic
if (module.type === 'js' && module.code.includes('useResponsiveValue')) {
// Custom handling for useResponsiveValue calls
console.log('Found useResponsiveValue call');
}
},
onError: (error, context) => {
// Custom error handling
console.error(`Transform error in ${context.filename}:`, error.message);
// Send to error reporting service
if (process.env.ERROR_REPORTING_URL) {
fetch(process.env.ERROR_REPORTING_URL, {
method: 'POST',
body: JSON.stringify({ error: error.message, context })
});
}
}
})
]
});
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
// Development configuration
...(process.env.NODE_ENV === 'development' ? [
reactResponsiveEasy({
precompute: false,
development: true,
addComments: true,
validateConfig: true
})
] : []),
// Production configuration
...(process.env.NODE_ENV === 'production' ? [
reactResponsiveEasy({
precompute: true,
development: false,
enableOptimization: true,
enableCaching: true
})
] : [])
]
});
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
import legacy from '@vitejs/plugin-legacy';
import compression from 'vite-plugin-compression';
export default defineConfig({
plugins: [
// React Responsive Easy plugin (should come early)
reactResponsiveEasy({
precompute: true,
development: process.env.NODE_ENV === 'development'
}),
// React plugin
react(),
// Legacy browser support
legacy({
targets: ['defaults', 'not IE 11']
}),
// Compression (in production)
...(process.env.NODE_ENV === 'production' ? [
compression({
algorithm: 'gzip',
ext: '.gz'
})
] : [])
]
});
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
precompute: process.env.ENABLE_PRECOMPUTE === 'true',
development: process.env.NODE_ENV === 'development',
// Conditional features based on environment
enableCaching: process.env.NODE_ENV === 'production',
performanceMetrics: process.env.NODE_ENV === 'development',
// Feature flags
features: {
advancedOptimizations: process.env.ADVANCED_OPTIMIZATIONS === 'true',
experimentalTransforms: process.env.EXPERIMENTAL === 'true'
}
})
],
// Environment variables
define: {
__RRE_VERSION__: JSON.stringify(process.env.npm_package_version),
__RRE_ENV__: JSON.stringify(process.env.NODE_ENV)
}
});
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
precompute: true,
performanceMetrics: true,
onTransform: (module, context) => {
// Collect performance metrics
const startTime = performance.now();
// ... transformation logic ...
const endTime = performance.now();
const duration = endTime - startTime;
// Log performance data
console.log(`Transform took ${duration.toFixed(2)}ms`);
// Send to monitoring service
if (process.env.MONITORING_URL) {
fetch(process.env.MONITORING_URL, {
method: 'POST',
body: JSON.stringify({
metric: 'transform_duration',
value: duration,
filename: context.filename,
timestamp: Date.now()
})
});
}
}
})
]
});
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
precompute: true,
// Performance budgets
performance: {
maxTransformTime: 100, // ms
maxBundleSizeIncrease: '50KB',
maxMemoryUsage: '100MB'
},
onTransform: (module, context) => {
// Check performance budgets
if (context.transformTime > 100) {
console.warn(`Transform took ${context.transformTime}ms (budget: 100ms)`);
}
}
})
]
});
# Start development server
npm run dev
# Start with specific options
npm run dev -- --port 3001 --host 0.0.0.0
# Start with HTTPS
npm run dev -- --https
The plugin provides enhanced HMR for responsive components:
import { useResponsiveValue } from '@yaseratiar/react-responsive-easy-core';
const Button = () => {
const fontSize = useResponsiveValue(16, { token: 'fontSize' });
const padding = useResponsiveValue(12, { token: 'spacing' });
return (
<button style={{ fontSize, padding }}>
Click me
</button>
);
};
// Changes to responsive values will trigger HMR
// without losing component state
# Enable debug logging
DEBUG=rre:vite-plugin npm run dev
# Enable verbose output
RRE_DEBUG=true npm run dev
# Show transformation details
RRE_SHOW_TRANSFORMATIONS=true npm run dev
# Build for production
npm run build
# Build with analysis
npm run build -- --analyze
# Build with profiling
npm run build -- --profile
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
import { visualizer } from 'rollup-plugin-visualizer';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
precompute: true,
enableOptimization: true
}),
// Bundle analyzer
visualizer({
filename: 'dist/stats.html',
open: true,
gzipSize: true,
brotliSize: true
})
]
});
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy({
precompute: true
})
],
build: {
rollupOptions: {
output: {
manualChunks: {
// Core responsive functionality
'responsive-core': ['@yaseratiar/react-responsive-easy-core'],
// Responsive hooks
'responsive-hooks': [
'@yaseratiar/react-responsive-easy-core/useResponsiveValue',
'@yaseratiar/react-responsive-easy-core/useBreakpoint'
],
// Responsive utilities
'responsive-utils': [
'@yaseratiar/react-responsive-easy-core/utils'
]
}
}
}
}
});
Before:
// package.json
{
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build"
}
}
After:
// package.json
{
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy()
]
});
Before:
// webpack.config.js
module.exports = {
plugins: [
new ReactResponsiveEasyWebpackPlugin()
]
};
After:
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy()
]
});
Before:
// .parcelrc
{
"extends": "@parcel/config-default",
"transformers": {
"*.{js,mjs,jsx,cjs,ts,tsx}": ["@parcel/transformer-js"]
}
}
After:
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { reactResponsiveEasy } from '@yaseratiar/react-responsive-easy-vite-plugin';
export default defineConfig({
plugins: [
react(),
reactResponsiveEasy()
]
});
# Check if plugin is installed
npm list @yaseratiar/react-responsive-easy-vite-plugin
# Verify Vite configuration
npx vite --version
# Check for syntax errors
npx vite build
# Validate configuration
RRE_VALIDATE_CONFIG=true npm run build
# Check configuration file
node -e "console.log(require('./responsive.config.js'))"
# Test with minimal config
RRE_MINIMAL_CONFIG=true npm run build
# Check build output
npm run build -- --verbose
# Enable debug mode
DEBUG=rre:vite-plugin npm run build
# Show transformation details
RRE_SHOW_TRANSFORMATIONS=true npm run build
# Show plugin version
npx vite --version
# List all Vite plugins
npx vite --help
# Test specific file
npx vite build src/components/Button.tsx
# Show build info
npx vite build --mode development
# Enable debug mode
DEBUG=rre:vite-plugin npm run dev
# Show help
npx @yaseratiar/react-responsive-easy-vite-plugin --help
# Check documentation
open https://github.com/naaa-G/react-responsive-easy
We welcome contributions! Please see our Contributing Guide for details.
# Clone repository
git clone https://github.com/naaa-G/react-responsive-easy.git
# Install dependencies
pnpm install
# Link plugin locally
pnpm --filter=@yaseratiar/react-responsive-easy-vite-plugin link
# Test plugin
pnpm test
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run specific test
pnpm test --grep "transformation"
# Coverage report
pnpm test:coverage
# Build plugin
pnpm build
# Build with watch mode
pnpm build:watch
# Build for production
pnpm build:prod
MIT License - see the LICENSE file for details.
Made with ❤️ by naa-G
⭐ Star this repository if you find it helpful!
FAQs
Vite plugin for React Responsive Easy integration
We found that @yaseratiar/react-responsive-easy-vite-plugin 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
Feross Aboukhadijeh joins TBPN to discuss Socket's $60M Series C, 500%+ ARR growth, AI's impact on open source, and the rise in supply chain attacks.

Security News
OSV withdrew 157 OSV malware reports after automated false positives incorrectly flagged trusted npm and PyPI packages, sending bad records into tools that rely on OSV data.

Research
/Security News
TrapDoor crypto stealer hits 36 malicious packages across npm, PyPI, and Crates.io, targeting crypto, DeFi, AI, and security developers.