Registry / devops / grapesjs-cli

grapesjs-cli

JSON →
library4.1.3jsnpmunverified

GrapesJS CLI is a command-line interface tool designed to streamline the development of GrapesJS plugins. It handles the complexities of setting up modern JavaScript build tools such as Webpack and Babel, providing a simplified and accelerated workflow for plugin authors. The current stable version, 4.1.3, focuses on dependency updates and build enhancements like the `dts` option. Historically, the CLI has undergone significant updates, including a transition to Webpack 5 in v3.0.0 and a move away from the `esm` package for internal bundling in v4.1.0, which can impact custom configurations. Its release cadence generally aligns with major GrapesJS ecosystem changes or critical dependency updates. Key differentiators for `grapesjs-cli` include its opinionated, zero-configuration approach for common plugin development scenarios, direct integration with the GrapesJS plugin structure, and features like fast project scaffolding and a built-in development server. It aims to reduce the boilerplate and configuration overhead for developers, allowing them to focus on the core plugin logic.

npm install grapesjs-cli
INSTALL
IMPORT
SIG · GRAPESJS-CLI
G
grapesjs-cli
devopsjavascriptv4.1.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

init
npx grapesjs-cli init
import { init } from 'grapesjs-cli'
GrapesJS CLI is a command-line tool. Commands are executed via `npx` or a global installation. Programmatic `import` or `require` of its internal modules is not supported for public API.
serve
npx grapesjs-cli serve
const serve = require('grapesjs-cli').serve
Starts a development server with live reloading, primarily for plugin development. Supports `webpack-dev-server` options via CLI arguments.
build
npx grapesjs-cli build
require('grapesjs-cli/dist/build')
Compiles and bundles the GrapesJS plugin into production-ready, minified JavaScript files. Generates a `dist/index.js` output by default since v3.0.0.

Demonstrates the typical GrapesJS plugin development workflow including project initialization, serving, building, and an example of customizing the Webpack configuration using TypeScript types.

/** * This quickstart demonstrates the GrapesJS plugin development workflow using grapesjs-cli. * The commands below are intended to be run in a shell environment. */ // 1. Create a new directory for your plugin and initialize it // mkdir grapesjs-my-plugin // cd grapesjs-my-plugin // npm init -y // git init // 2. Install the GrapesJS CLI as a development dependency // npm i -D grapesjs-cli // 3. Initialize your plugin project. Use '-y' to skip interactive questions. // npx grapesjs-cli init -y --user=your-github-username // 4. Start the development server. Access your plugin demo at http://localhost:8080. // npx grapesjs-cli serve // You can also pass custom webpack-dev-server options: // npx grapesjs-cli serve --devServer='{"https": true}' // 5. Build your plugin for production. This generates output in the 'dist' directory. // npx grapesjs-cli build // Example: Custom webpack.config.js for advanced configurations (placed in your plugin's root directory) // This JavaScript code block is runnable as a conceptual example of the config file structure. /** @type {import('webpack').Configuration} */ const customWebpackConfig = ({ config }) => { // `config` is the default webpack configuration provided by grapesjs-cli const isBuild = config.mode === 'production'; // Differentiate build from serve command return { ...config, // Example: Add a new rule for handling SVG files module: { rules: [ { test: /\.svg$/, use: ['@svgr/webpack'], }, ...config.module.rules, ], }, // Example: Customize an existing plugin or add a new one plugins: [ ...(config.plugins || []), // new MyCustomWebpackPlugin(), ], }; }; // In a real scenario, this would be exported from a webpack.config.js file: // export default customWebpackConfig; console.log('GrapesJS CLI workflow and custom webpack config demonstrated.');
grapesjs --version
Debug
Known issues
breakingGrapesJS CLI v3.0.0 upgraded to Webpack 5. Custom `webpack.config.js` files may need updates to avoid deprecated options or configurations from Webpack 4.
fix
Review your `webpack.config.js` against Webpack 5 documentation and update deprecated options, loaders, and plugins.
affects: >=3.0.0
breakingWith v3.0.0, the output filenames changed from `dist/my-plugin-name.min.js` to `dist/index.js`. This affects how your plugin is referenced.
fix
Update the `main` field in your plugin's `package.json` to point to `dist/index.js`.
affects: >=3.0.0
breakingNode.js 14.15.0 or newer is required since v4.0.0. Older versions of Node.js are no longer supported and will cause the CLI to fail.
fix
Upgrade your Node.js environment to version 14.15.0 or later.
affects: >=4.0.0
breakingVersion 4.1.0 moved away from the `esm` package for bundling the CLI internally. While this primarily affects the CLI's internal workings, custom setups that relied on the previous bundling approach might be impacted.
fix
No direct fix for users, but if experiencing unexpected build issues, ensure your environment and custom scripts are compatible with a self-bundled CLI.
affects: >=4.1.0
gotchaWhen customizing Webpack through `webpack.config.js`, you must export a function that receives the default configuration object and returns a new one.
fix
Ensure your `webpack.config.js` exports a function: `export default ({ config }) => { /* ... */ return { ...config, /* ... */ }; }`.
affects: >=1.0.14
gotchaPassing options to `webpack-dev-server` via the `serve` command requires a specific JSON string format.
fix
Use the `--devServer` flag with a JSON string, e.g., `npx grapesjs-cli serve --devServer='{"https": true}'`.
affects: >=1.0.0
Errors
Common errors & fixes
Webpack options object has an unknown property '...' (e.g., 'resolve.modules'). These options were deprecated in webpack 4 and removed in webpack 5.
Using an outdated `webpack.config.js` that contains Webpack 4-specific configurations after upgrading grapesjs-cli to v3.0.0 (Webpack 5).
fix
Refer to the Webpack 5 migration guide and update your custom `webpack.config.js` to use current options and syntax.
Error: Cannot find module 'your-plugin-name'
The `main` entry in your plugin's `package.json` still points to the old output path (e.g., `dist/my-plugin-name.min.js`) after the v3.0.0 breaking change.
fix
Update your `package.json` `main` field to `dist/index.js`.
Error: No valid `src/index.js` (or `src/index.ts`) entry file found for your plugin.
The required entry point file for your GrapesJS plugin is missing or incorrectly named in the `src` directory.
fix
Ensure you have an `index.js` or `index.ts` file located directly under the `src/` directory of your plugin project.
Node.js version 12.x.x is not supported. Minimum supported Node.js version is 14.15.0.
Attempting to run `grapesjs-cli` with an older Node.js version than required by the CLI (v4.0.0 and above).
fix
Upgrade your Node.js installation to version 14.15.0 or newer.
Upgrade
Version history
4.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources