Intelligent Webpack Config Generator

1.4.0 · active · verified Tue Apr 21

packjs is a command-line interface (CLI) tool designed to simplify webpack configuration. It acts as an "intelligent bundler" by generating complex webpack setups from simpler, higher-level configuration inputs. The package aims to automate the installation of necessary dependencies and supports features like HTTPS certificates for development. As of version 1.4.0, it primarily targets Node.js environments (requiring Node.js >=10.13.0). Its key differentiator is abstracting away much of the boilerplate and complexity often associated with manual webpack configuration, making it suitable for developers who prefer a more streamlined build process without diving deep into webpack internals. The official documentation can be found on its project website.

Common errors

Warnings

Install

Quickstart

This quickstart demonstrates how to set up `packjs` with a configuration file (`packjs.config.js`) and integrate its CLI commands into `package.json` scripts for development and production builds. It highlights the primary interaction model, which is through the command line, and assumes `webpack` and `webpack-cli` are installed to execute the generated configurations.

/* packjs.config.js */
// Example packjs configuration file
// This file would typically be consumed by the `packjs` CLI.

module.exports = {
  entry: './src/index.js',
  output: {
    path: './dist',
    filename: 'bundle.js',
    clean: true
  },
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  devServer: {
    port: 8080,
    open: true,
    hot: true,
    https: true // packjs supports HTTPS certificates
  },
  // Additional packjs specific high-level configurations
  // which packjs translates into detailed webpack options.
  features: {
    react: true,
    typescript: false,
    cssModules: true
  }
};

/* package.json */
// Add scripts to run packjs
{
  "name": "my-app-with-packjs",
  "version": "1.0.0",
  "description": "A project using packjs for bundling",
  "main": "index.js",
  "scripts": {
    "dev": "packjs serve",
    "build": "packjs build --env production"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "packjs": "^1.4.0",
    "webpack": "^5.x.x",
    "webpack-cli": "^5.x.x",
    "webpack-dev-server": "^4.x.x" // Often required for 'serve' command
  }
}

// To run:
// 1. npm install --save-dev packjs webpack webpack-cli webpack-dev-server
// 2. Create 'src/index.js' (e.g., console.log('Hello packjs!');)
// 3. Create 'packjs.config.js' as above.
// 4. Run `npm run dev` to start development server.
// 5. Run `npm run build` to create a production bundle.

view raw JSON →