Skip to content

Commit

Permalink
new readme for adding scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aorcsik committed May 10, 2024
1 parent 28520a5 commit 88b3273
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,62 @@
# Webflow Scripts

## Development
## Adding Standalone Non-compiled Scripts

Create the file in the `dist/standalone/` folder, like

```
dist/standalone/my-script.js
```

After merging into main, it will be available as

```
https://webflow-scripts.bitrise.io/standalone/my-script.js
```

## Adding compiled scripts

Create the entry point in the `src/js/` folder. You implement these script like any other JS project with ES6 modules. You can import the CSS files too, they will be included in the compiled bundle. For example:

CSS: `src/css/my-styles.css`

JS: `src/js/my-script.js`
```javascript
import { loadCss } from "./shared/common";

loadCss(require("../css/my-styles.css"));

window.addEventListener('load', async () => {
console.log('Hello World!');
});
```

After merging into main, it will be available as

```
https://webflow-scripts.bitrise.io/my-script.js
```

## Developing with the local environment

After cloning,

build scripts with webpack, use `--watch` if needed

```
```sh
yarn build_dev
```

and start server with

```
node index.js <webflow-environment>
```sh
node index.js "<webflow-environment>" "<local-domain (optional)>"
```

The local server will proxy paths from the `<webflow-environment>` and replace the script with the local one.
The local server will proxy paths from the `<webflow-environment>` and replace the script that are already embedded in the page with the local one.

### Using Temp Files

Loading an html file from the temp folder will bypass the webflow proxy.

You have to directly reference the script to be used in the temp file, the replce won't happen in this case.
You have to directly reference the script to be used in the temp file, the replace won't happen in this case.

0 comments on commit 88b3273

Please sign in to comment.