
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@danielhaim/packr
Advanced tools
Fast asset pipeline built in Rust for processing JavaScript and SCSS
A fast asset pipeline built in Rust for processing JavaScript and SCSS.
# Install from npm
npm install @danielhaim/packr
# Or install globally
npm install -g @danielhaim/packr
Packr can be used via the JavaScript API, a packr.json config file, or the CLI.
const packr = require('@danielhaim/packr');
packr({
scss_input: 'src/scss/app.scss',
scss_output: 'dist/app.css',
js_input: 'src/js/app.js',
js_output: 'dist/app.js',
minify: true,
watch: false
});
Create a .packr.json in your project root:
{
"scss_input": "src/scss/app.scss",
"scss_output": "dist/app.css",
"js_input": "src/js/app.js",
"js_output": "dist/app.js",
"css_destination": "public/css",
"js_destination": "public/js",
"minify": true,
"target": "es2020",
"verbose": true,
"sourcemap": true,
"format": "iife",
"watch": true
}
Then run:
const packr = require('@danielhaim/packr');
packr(); // Loads from .packr.json
# Default config (.packr.json)
packr
# Use a specific config file
packr --config custom/packr.json
# Enable watch mode
packr --watch
| Option | Type | Default | Description |
|---|---|---|---|
scss_input | string | required | Path to SCSS input file |
scss_output | string | required | Path to SCSS output file |
js_input | string | required | Path to JavaScript input file |
js_output | string | required | Path to JavaScript output file |
css_destination | string | — | Optional alternate output path for CSS |
js_destination | string | — | Optional alternate output path for JS |
minify | boolean | true | Minify the output |
target | string | 'es2020' | JavaScript target version |
watch | boolean | false | Watch files for changes |
verbose | boolean | false | Enable extra console output |
sourcemap | boolean | false | Include source maps in the output |
format | string | 'iife' | Output format: iife, cjs, or esm |
eslint | boolean | false | Enable ESLint checking |
eslint_config | string | — | Path to custom ESLint config file |
Packr supports configuration through environment variables, which can be set in environment files in your project root. This allows for flexible configuration across different environments.
Packr loads environment variables from the following files in order of precedence (highest to lowest):
.env (base configuration).env-{NODE_ENV} (e.g., .env-production, .env-staging).env-local (only in development mode)When working with environment files and sensitive data:
File Security
.env files to version control.env.example as a template (included in repo)chmod 600 .env*Sensitive Data
Production Checks
Development Safety
.env-local for development-only values.env.example| Variable | Description | Default |
|---|---|---|
PACKR_SCSS_INPUT | Path to SCSS input file | - |
PACKR_SCSS_OUTPUT | Path to output compiled CSS | - |
PACKR_JS_INPUT | Path to JavaScript input file | - |
PACKR_JS_OUTPUT | Path to output bundled JS | - |
PACKR_CSS_DESTINATION | Output directory for CSS | - |
PACKR_JS_DESTINATION | Output directory for JS | - |
PACKR_MINIFY | Minify output | true |
PACKR_TARGET | JavaScript target | es2020 |
PACKR_VERBOSE | Enable verbose logging | false |
PACKR_SOURCEMAP | Generate source maps | false |
PACKR_FORMAT | JavaScript output format (iife, cjs, esm) | iife |
PACKR_ESLINT | Enable ESLint | false |
PACKR_ESLINT_CONFIG | Path to ESLint config | - |
PACKR_MINIFY_JS | JavaScript-specific minification | true |
PACKR_MINIFY_CSS | CSS-specific minification | true |
PACKR_UGLIFY_MANGLE | Enable name mangling | true |
PACKR_UGLIFY_KEEP_FNAMES | Preserve function names | false |
PACKR_UGLIFY_KEEP_CLASSNAMES | Preserve class names | false |
PACKR_UGLIFY_RESERVED | Comma-separated list of names to preserve | - |
PACKR_SCSS_INPUT=src/scss/app.scss
PACKR_SCSS_OUTPUT=dist/app.css
PACKR_JS_INPUT=src/js/app.js
PACKR_JS_OUTPUT=dist/app.js
PACKR_CSS_DESTINATION=public/css
PACKR_JS_DESTINATION=public/js
PACKR_MINIFY=true
PACKR_TARGET=es2020
PACKR_VERBOSE=false
PACKR_SOURCEMAP=false
PACKR_FORMAT=iife
PACKR_ESLINT=false
Environment variables take precedence over configuration file options, allowing you to override settings for specific environments without changing your configuration files.
Packr provides granular control over minification and uglification:
PACKR_MINIFY: Global switch for all minification (default: true)PACKR_MINIFY_JS: JavaScript-specific minification (default: true)PACKR_MINIFY_CSS: CSS-specific minification (default: true)PACKR_UGLIFY_MANGLE: Enable name mangling (default: true)PACKR_UGLIFY_KEEP_FNAMES: Preserve function names (default: false)PACKR_UGLIFY_KEEP_CLASSNAMES: Preserve class names (default: false)PACKR_UGLIFY_RESERVED: Comma-separated list of names to preserve (e.g., jQuery,$)Example configuration in .packr.json:
{
"minify": true,
"minify_js": true,
"minify_css": true,
"uglify": {
"mangle": true,
"keep_fnames": false,
"keep_classnames": false,
"reserved": ["jQuery", "$"]
}
}
The minification process:
JavaScript:
CSS:
Packr includes a comprehensive test suite that covers various build scenarios:
Default Configuration
Custom Config File
ESM Format
No Sourcemaps
Minification
.min file generationESLint Integration
# Run all tests
node __tests__/test.js
# Run specific test
node __tests__/test.js --test "Default Packr Configuration"
node __tests__/test.js --test "Custom Config File"
node __tests__/test.js --test "ESM Format"
node __tests__/test.js --test "No Sourcemaps"
node __tests__/test.js --test "Minification"
node __tests__/test.js --test "ESLint"
Packr includes built-in ESLint support for JavaScript files:
{
"eslint": true,
"eslintConfig": ".eslintrc.json"
}
ESLint warnings are displayed in a detailed format:
File: src/js/app.js
Warnings:
Line 8, Column 5: no-var - Unexpected var, use let or const instead.
Line 15, Column 9: prefer-const - 'y' is never reassigned. Use 'const' instead.
Line 16, Column 13: semi - Missing semicolon.
Line 38, Column 5: no-var - Unexpected var, use let or const instead.
Packr uses Rust for fast and efficient asset builds:
grassesbuildlightningcss.env, NODE_ENV, etc.)See the Contributing Guide for details on submitting issues or PRs.
If you find a security issue, please report it privately via a GitHub discussion. Avoid using the issue tracker.
Packr is licensed under the Apache License 2.0.
Packr is built with:
FAQs
Fast asset pipeline built in Rust for processing JavaScript and SCSS
We found that @danielhaim/packr 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
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.