@webflow/webflow-cli 1.12.0 → 1.12.1

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