@webflow/webflow-cli 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @webflow/webflow-cli
2
2
 
3
+ ## 1.12.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 51547bc: Fix library bundling error with code component declaration file name starting with a number
8
+
9
+ ## 1.12.1
10
+
11
+ ### Patch Changes
12
+
13
+ - dbf223b: Support function-based and array bundle config overrides for environment-specific webpack configurations
14
+ - b50be36: Streamlined `library bundle` command for faster execution and added `--skip-update-check` global option to skip checking for `@webflow` packages updates.
15
+ - Updated dependencies [dbf223b]
16
+ - @webflow/data-types@1.2.1
17
+
3
18
  ## 1.12.0
4
19
 
5
20
  ### Minor Changes
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Webflow CLI
1
+ # @webflow/webflow-cli
2
2
 
3
3
  The Webflow CLI is a command-line interface that allows you to interact with various Webflow developer products, including Devlink and Designer Extensions.
4
4
 
@@ -10,16 +10,285 @@ You can install the Webflow CLI globally on your machine using npm:
10
10
  npm i @webflow/webflow-cli -g
11
11
  ```
12
12
 
13
- # Usage
13
+ ## Usage
14
14
 
15
+ - [Code Components Libraries](#code-components-libraries)
15
16
  - [Webflow Designer APIs & Extensions](#webflow-designer-apis-and-extensions)
16
17
  - [Devlink](#devlink)
17
18
 
18
- ## Webflow Designer Extensions and APIs
19
+ ### Global Options
20
+
21
+ The following options are available for all commands:
22
+
23
+ - **`--no-input`** - Avoid prompting or doing anything interactive. Use this for CI/CD pipelines.
24
+ - **`--manifest <path>`** - Path to a manifest .json file or directory containing webflow.json. Default: `./webflow.json`
25
+ - **`--skip-update-check`** - Skip checking for `@webflow` packages updates
26
+
27
+ ### Code Components Libraries
28
+
29
+ [Code Components](https://developers.webflow.com/code-components/introduction) allow you to build custom React components and share them to your Webflow workspace. The Webflow CLI provides commands to manage and share your component libraries.
30
+
31
+ #### Prerequisites
32
+
33
+ Before using the library commands, you need to create a `webflow.json` configuration file in your project root. Here's an example:
34
+
35
+ ```json
36
+ {
37
+ "library": {
38
+ "name": "My Component Library",
39
+ "description": "A collection of custom components",
40
+ "components": ["src/components/**/*.webflow.tsx"]
41
+ }
42
+ }
43
+ ```
44
+
45
+ **Configuration Options:**
46
+
47
+ - **`name`** (required): The display name of your library
48
+ - **`description`** (optional): A description of your library
49
+ - **`components`** (required): Glob pattern(s) for your component files
50
+ - **`id`** (optional): Library ID (auto-generated on first share)
51
+ - **`renderer`** (optional): Custom renderer configuration
52
+ - Can be a string path to a renderer module
53
+ - Or an object with `client` and `server` paths
54
+ - **`bundleConfig`** (optional): Path to a webpack configuration file for custom bundle overrides
55
+
56
+ #### Sharing a Library
57
+
58
+ Share your component library to your Webflow workspace:
59
+
60
+ ```shell
61
+ webflow library share
62
+ ```
63
+
64
+ This command will:
65
+
66
+ 1. Collect metadata from your component files
67
+ 2. Bundle your components for both client and server environments
68
+ 3. Upload the bundles to Webflow's CDN
69
+ 4. Register the library in your workspace
70
+
71
+ ##### Authentication
72
+
73
+ You need a Workspace API token to share libraries. On your first share, the CLI will guide you through an OAuth flow to authenticate and generate a token.
74
+
75
+ Alternatively, you can provide a token manually with an environment variable:
76
+
77
+ ```shell
78
+ export WEBFLOW_WORKSPACE_API_TOKEN=your_token_here
79
+ webflow library share
80
+ ```
81
+
82
+ You can generate a Workspace API token in your Webflow workspace settings.
83
+
84
+ ##### Options
85
+
86
+ - **`--api-token <token>`** - Workspace API token (overrides environment variable)
87
+ - **`--force`** - Force compilation even with warnings or type errors
88
+ - **`--debug-bundler`** - Display final bundler configurations for debugging
89
+ - **`--dev`** - Bundle in development mode for debugging
90
+ - **`--verbose`** - Display more detailed information
91
+
92
+ #### Bundling for Local Development
93
+
94
+ Bundle your library locally without sharing to Webflow:
95
+
96
+ ```shell
97
+ webflow library bundle --public-path /public
98
+ ```
99
+
100
+ This is useful for:
101
+
102
+ - Testing your components locally
103
+ - Debugging bundle issues
104
+
105
+ ##### Options
106
+
107
+ - **`--public-path <path>`** (required) - Public path for the bundle
108
+ - **`--output-path <path>`** - Output directory (default: `./dist`)
109
+ - **`--force`** - Force compilation even with warnings or type errors
110
+ - **`--debug-bundler`** - Display final bundler configurations
111
+ - **`--dev`** - Bundle in development mode
112
+ - **`--verbose`** - Display more detailed information
113
+
114
+ The bundled files will be written to the output directory with separate `client` and `server` subdirectories.
115
+
116
+ #### Viewing Logs
117
+
118
+ Display the logs directory and path to the latest log file:
119
+
120
+ ```shell
121
+ webflow library log
122
+ ```
123
+
124
+ This is helpful for debugging issues with the `share` or `bundle` commands.
125
+
126
+ #### Customizing Bundle Configuration
127
+
128
+ You can customize the webpack configuration used to bundle your components by providing a `bundleConfig` option in your `webflow.json` file. This allows you to add custom loaders, plugins, or modify the build process.
129
+
130
+ ##### Configuration File
131
+
132
+ In your `webflow.json`, specify the path to your bundle config file:
133
+
134
+ ```json
135
+ {
136
+ "library": {
137
+ "name": "My Component Library",
138
+ "components": ["src/components/**/*.webflow.tsx"],
139
+ "bundleConfig": "./webpack.webflow.js"
140
+ }
141
+ }
142
+ ```
143
+
144
+ ##### Bundle Config Format
145
+
146
+ Your bundle config file can export configurations in three ways:
147
+
148
+ **1. Static Object**
149
+
150
+ Export a static configuration object:
151
+
152
+ ```js
153
+ // webpack.webflow.js
154
+ module.exports = {
155
+ mode: "production",
156
+ devtool: "source-map",
157
+ module: {
158
+ rules: (currentRules) => [
159
+ ...currentRules,
160
+ { test: /\.svg$/, use: ["@svgr/webpack"] },
161
+ ],
162
+ },
163
+ };
164
+ ```
165
+
166
+ **2. Function (Environment-Specific)**
167
+
168
+ Export a function that receives the environment (`Environment.Client` or `Environment.Server`) and returns a configuration:
169
+
170
+ ```js
171
+ // webpack.webflow.js
172
+ const { Environment } = require("@webflow/data-types");
173
+
174
+ module.exports = (env) => ({
175
+ mode: env === Environment.Client ? "production" : "development",
176
+ devtool: env === Environment.Client ? "source-map" : false,
177
+ module: {
178
+ rules: (currentRules) => [
179
+ ...currentRules,
180
+ {
181
+ test: env === Environment.Client ? /\.client\.js$/ : /\.server\.js$/,
182
+ use: "custom-loader",
183
+ },
184
+ ],
185
+ },
186
+ });
187
+ ```
188
+
189
+ **3. Array (Multiple Configs)**
190
+
191
+ Export an array of objects and/or functions to merge multiple configurations:
192
+
193
+ ```js
194
+ // webpack.webflow.js
195
+ const { Environment } = require("@webflow/data-types");
196
+ const {
197
+ styledComponentsBundleConfig,
198
+ } = require("@webflow/styled-components-utils");
199
+
200
+ module.exports = [
201
+ // Include third-party config
202
+ styledComponentsBundleConfig,
203
+
204
+ // Add environment-specific settings
205
+ (env) => ({
206
+ mode: env === Environment.Client ? "production" : "development",
207
+ }),
208
+
209
+ // Add custom rules
210
+ {
211
+ module: {
212
+ rules: (currentRules) => [
213
+ ...currentRules,
214
+ { test: /\.svg$/, use: ["@svgr/webpack"] },
215
+ ],
216
+ },
217
+ },
218
+ ];
219
+ ```
220
+
221
+ ##### Common Use Cases
222
+
223
+ **Adding a Custom Loader**
224
+
225
+ ```js
226
+ module.exports = {
227
+ module: {
228
+ rules: (currentRules) => [
229
+ ...currentRules,
230
+ {
231
+ test: /\.scss$/,
232
+ use: ["style-loader", "css-loader", "sass-loader"],
233
+ },
234
+ ],
235
+ },
236
+ };
237
+ ```
238
+
239
+ **Modifying an Existing Loader**
240
+
241
+ ```js
242
+ module.exports = {
243
+ module: {
244
+ rules: (currentRules) =>
245
+ currentRules.map((rule) => {
246
+ // Extend the CSS loader configuration
247
+ if (rule.test instanceof RegExp && rule.test.test("test.css")) {
248
+ // Modify the rule...
249
+ return modifiedRule;
250
+ }
251
+ return rule;
252
+ }),
253
+ },
254
+ };
255
+ ```
256
+
257
+ **Using CSS-in-JS Library Configs**
258
+
259
+ ```js
260
+ const {
261
+ styledComponentsBundleConfig,
262
+ } = require("@webflow/styled-components-utils");
263
+
264
+ // For styled-components
265
+ module.exports = styledComponentsBundleConfig;
266
+ ```
267
+
268
+ ##### Merging Behavior
269
+
270
+ When multiple configs are provided (via array), they are merged with the following behavior:
271
+
272
+ - **Regular properties**: Later configs override earlier ones
273
+ - **Module rules**: Rules transformation functions are chained together in order
274
+ - **Plugins**: Plugin arrays are concatenated
275
+ - **ModuleFederationPlugin shared**: Shared dependency configurations are merged
276
+
277
+ ##### Blocked Properties
278
+
279
+ For security and consistency, the following webpack properties cannot be overridden:
280
+
281
+ - `entry`
282
+ - `output`
283
+ - `target`
284
+
285
+ Attempting to override these properties will result in a warning and they will be ignored.
286
+
287
+ ### Webflow Designer Extensions and APIs
19
288
 
20
289
  [Designer Extensions](https://docs.developers.webflow.com/v2.0.0/docs/apps-overview) are single-page web Apps that run inside of of the Webflow Designer, and manipulate elements on the canvas through [Webflow's Designer APIs.](https://docs.developers.webflow.com/v2.0.0/reference/introduction-1). You can use the Webflow CLI to develop and package your Designer Extensions.
21
290
 
22
- ### Creating an Extension
291
+ #### Creating an Extension
23
292
 
24
293
  To create a new extension, use the `webflow extension init` command:
25
294
 
@@ -29,7 +298,7 @@ webflow extension init my-extension
29
298
 
30
299
  This command creates a new directory named `my-extension` with a basic scaffold for your extension. See more details about the scaffolding on the [App structure reference](https://docs.developers.webflow.com/v2.0.0/reference/app-structure).
31
300
 
32
- ### Running your Extension Locally
301
+ #### Running your Extension Locally
33
302
 
34
303
  Navigate to the newly created folder for your extension. You can serve your extension locally using the following command. The default port is set to 1337.
35
304
 
@@ -39,11 +308,11 @@ npm run dev
39
308
 
40
309
  This will run the `webflow extension serve` and command, allowing you test your App locally.
41
310
 
42
- #### Options
311
+ ##### Options
43
312
 
44
313
  - `port` - Serve your extension at a specific port on localhost: `webflow extension serve 1234`
45
314
 
46
- ### Building and Bundling your Extension
315
+ #### Building and Bundling your Extension
47
316
 
48
317
  If you're using the scaffolding built out from the `webflow extension init` command, you can create a build of your extension, an bundle it for publishing using the` npm run build` command:
49
318
 
@@ -53,7 +322,7 @@ npm run build
53
322
 
54
323
  This will run the `webflow extension bundle` CLI command, which will output a `bundle.zip` file in your extension’s directory. You can upload this extension to Webflow via the "Integrations" tab in your workspace settings. Note: The extension size limit is 5MB.
55
324
 
56
- # Devlink
325
+ ### Devlink
57
326
 
58
327
  DevLink allows you to visually design and build web components for React directly in Webflow. [Learn more in our DevLink overview,](https://webflow.com/devlink) and read the [DevLink documentation](https://docs.developers.webflow.com/docs/devlink-documentation-and-usage-guide).
59
328
 
@@ -98,6 +367,6 @@ by going to Site Settings > Integrations.
98
367
  npx webflow devlink sync
99
368
  ```
100
369
 
101
- # Terms of Service
370
+ ## License
102
371
 
103
- By using Webflow DevLink you agree to the [Webflow Labs Terms of Service](https://webflow.com/legal/labs-terms).
372
+ MIT