Skip to content

Include some modern-js development ❤️ into Webflow.

Notifications You must be signed in to change notification settings

jack1913/webflow-typescript-scss-boilerplate

Repository files navigation

Webflow + Typescript + SCSS + Webpack with HMR + Prettier + ESLint + Visual Studio Code

Basic setup that you can use for your Webflow website with:

jQuery is declared as an dependance and flagged as external in webpack. Feel free to add more if you import dependencies directly in Webflow.


How to use with Webflow

First steps

  1. Clone the repo by clicking on Use this template.
  2. Install all of the dependancies with npm install
  3. Open VSCode.

Integrate into Webflow

  1. Open your webflow site, and add to a page (for ex. home) custom code before </body>:
<script type="module" src="http://localhost:8080/home.js"></script>
  1. In the same place add custom code to <head>:
<link rel="stylesheet" href="http://localhost:8080/home.css">

Developing

  1. Now let's go back to VSCode and run npm run serve and enjoy developing as it was meant to.
  2. This boilerplate has HMR implemented, so once you make any changes to the code it will be auto-updated on your webflow site.

Production

  1. Use npm build and upload the files from the ./dist folder onto your preferred CDN.
  2. Change imports in Webflow to those of your CDN.

Configuration

Open config.js.

Hostname (optional)

Your webflow site url, once specified on npm run serve it will open your site in the browser

Port

Default 8080. Feel free to change.

Pages

List of all pages you will be writing your code for. It's used by webpack to create separate entry points and chunks. For ex. we've home: './src/home.ts'. If you want to add another one then you create a new entry another: './scr/another.ts' - please use home.ts as a template.

Externals

List of all external dependencies that won't be bundled. By default jQuery is added.


Scripts

This project is using npm, but if you like yarn more, then feel free to switch to it. It doesn't really matter.

First, install dependencies:

npm install

To launch a local dev server:

npm run serve

To create a production build:

npm build

To clean the local /dist folder:

npm run clean

To lint the code with ESLint and Prettier:

npm run lint

Build commands in VSCode

Once you click CMD + SHIFT + B on Mac or CTR + SHIFT + B on Windows you can use prebuild task in VSCode.

Development

As a name suggests, it runs npm ren serve.

Build

Production-ready build with a sequence of npm run clean and npm build.