npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

import-webflow-export

v0.0.5

Published

Import a Webflow export repeatably.

Readme

import-webflow-export

Import a Webflow export repeatably.

If you want to continue editing a site in Webflow and then use the exported site, you really don't want to edit the exported site manually. Any manual edits will be overwritten each time you export the site from Webflow again.

You can use this command line tool to import files from standard Webflow locations to the locations in your project where those files should be.

You can also use this to perform a range of edits on the exported HTML files programmatically, so that it is repeatable and not overwritten or forgotten.

Use this for example to

  • Add a script tag for your javascript that calls an API and manipulates the webflow site with the retrieved content
  • Adds template tags for server-side templating e.g. in a Django app. This is useful for example for meta tags for search engines that don't execute javascript.

See our best practises building pages in webflow and then modifying the DOM based on data.

Installation

As a dev dependency

npm install --save-dev import-webflow-export

Or as a global command

npm install --global import-webflow-export

Usage

By default, the css, js, images, and fonts directories are copied to the same directory names in src and .html files in all folders are copied to the same directory structure in src without any transformations:

import-webflow webflow-export.zip

e.g.

Extracting to temporary directory /tmp/tmp-147494-K5wvv6RJG20P
Copying css to src/css
Copying js to src/js
Copying images to src/images
Copying fonts to src/fonts
Looking for files matching *.html in /tmp/tmp-147494-K5wvv6RJG20P
Reading /tmp/tmp-147494-K5wvv6RJG20P/index.html
No transformation module provided
Writing src/index.html
Cleaning up temporary directory /tmp/tmp-147494-K5wvv6RJG20P

You can customise the import by specifying configuration in your package.json file under the importWebflowExport key.

e.g.

{
  "name": "my-app",
  "version": "1.0.0",
  "scripts": {
    "dev": "parcel src/index.html"
  },
  "importWebflowExport": {
    "importHtml": [
      {
        "glob": "*.html",
        "destDir": "src",
        "transforms": "./src/js/webflow/import.js"
      }
    ]
  }
}

copyTrees

Each key is a directory name in the root of the Webflow export.

Each value is a string path where the source directory's contents will be copied to relative to the directory where you run import-webflow.

Default:

copyTrees: {
  "css": "src/css",
  "js": "src/js",
  "images": "src/images",
  "fonts": "src/fonts",
}

importHtml

Each item is an object with the keys

  • glob: a glob to match HTML filenames that will be processed by this item
  • destDir: the directory relative to the current working directory
  • transforms (optional): path to a transformation module relative to the current working directory when you run import-webflow.

Default:

importHtml: [
  {glob: "*.html", destDir: "src"}
],

HTML transformation modules

HTML can be transformed programmatically using Javascript transformation modules. You can perform specific transformations on specific HTML files by using specific glob pattern items in importHtml.

The file will be serialised and saved in the destination directory after transformation.

Each transformation module can export the following functions:

transformDOM

Transforms the DOM with side-effects of DOM and jQuery methods.

Argumets:

  • window: a DOM window object
  • $: a jQuery object initialised on the same window object.

e.g. for a file src/js/webflow/import.js

exports.transformDOM = function(window, $) {
  $("title").text("This was modified programmatically!");

  // Adding a script tag to body via jQuery seems to add it to head as well?!
  const tag = window.document.createElement("script");
  tagd.setAttribute("src", "js/index.js");
  window.document.body.appendChild(tag);
};

and config

"importHtml": [
  {
    "glob": "*.html",
    "destDir": "src",
    "transforms": "./src/js/webflow/import.js"
  }
]
transformHTML

Returns a modified HTML string.

Arguments:

  • html: String

e.g.

exports.transformHTML = function(html) {
  // Load Django template tags
  let newHtml = "{% load static %}\n" + html;

  // Replace asset paths with Django Static asset paths
  newHtml = newHtml.replace(/"(js|css|images|fonts)\//g, "\"/static/$1/");
  return newHtml;
};

More examples

Make the title and og:title tag dynamic when using the HTML file as a Django template.

Also adds an og:description tag.

exports.transformDOM = function(window, $) {
  $("title").text("{{ page_title }}");
  $('meta[property="og:title"]').attr("content", "{{ page_title }}");

  $("head").append('<meta property="og:description" content="{{ page_description }}">\n');
}