Powerlines: The Framework Framework

0.42.41 · active · verified Sun Apr 19

Powerlines is a 'framework framework' and build toolkit (currently at version 0.42.41) designed to simplify the use of modern development tools and improve developer experience. Developed by Storm Software, it achieves this by providing a unified abstraction layer over various build ecosystems such as Vite, Rollup, Webpack, esbuild, Nuxt, Astro, and Next.js. It supports generating virtual or actual code modules, streamlining complex build configurations. The project maintains a very active, rapid release cadence with frequent updates across its core and plugin packages, reflecting its ongoing development. Its key differentiator is its ambition to be a meta-framework, offering a consistent approach to tooling integration and module generation, contrasting with single-bundler-focused solutions. While highly functional, it is still in an initial development phase, and users should expect potential bugs and API evolution.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates setting up `powerlines.config.ts` with `definePowerlinesConfig`, integrating Vite and esbuild plugins, and adding a custom plugin with basic hooks.

import { definePowerlinesConfig } from 'powerlines';
import { createVitePlugin } from '@powerlines/plugin-vite';
import { createEsbuildPlugin } from '@powerlines/plugin-esbuild';

export default definePowerlinesConfig({
  /**
   * Project-wide options for Powerlines.
   * For example, specifying where virtual modules should be resolved from.
   */
  output: {
    dir: './dist',
    clean: true
  },
  /**
   * Define your Powerlines plugins here.
   * These plugins can interact with various build tools.
   */
  plugins: [
    createVitePlugin({
      // Vite specific options
      optimizeDeps: {
        exclude: ['my-excluded-lib']
      }
    }),
    createEsbuildPlugin({
      // esbuild specific options
      target: 'es2022',
      minify: process.env.NODE_ENV === 'production'
    }),
    {
      name: 'my-custom-plugin',
      setup(powerlines) {
        // Example hook: Intercepting a build event
        powerlines.onBuildStart(() => {
          console.log('Custom plugin: Powerlines build started!');
        });
        // You can register virtual modules, transform code, etc.
      }
    }
  ],
  /**
   * Optional: Define global constants or environment variables
   * that Powerlines can inject into your builds.
   */
  define: {
    __APP_VERSION__: JSON.stringify('1.0.0'),
    __API_URL__: JSON.stringify(process.env.API_URL ?? 'http://localhost:3000')
  }
});

view raw JSON →