Skip to content
Automatically moves html-files from lektors assets folder into lektors templates folder.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


PyPI version Downloads

This is a plugin for Lektor that adds support for generating templates with webpacks HtmlWebpackPlugin. These templates can be generated into Lektors assets folder which will be observed for newly created or modified html files. These files will then be copied over to Lektors templates folder so that they can be used by Lektor. This plugin depends on the lektor-webpack-support plugin to be really useful.


const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

module.exports = {
    mode: "production",
    entry: {
        main: "./src/index.js"
    output: {
        filename: "[name].bundle.js",
        path: path.dirname(__dirname) + "/assets/generated" 
    optimization: {
        minimizer: [
            new HtmlWebpackPlugin({
                inject: false,
                filename: "layout_generated.html",
                template: "./src/layout_template.html"
    plugins: [
        new CleanWebpackPlugin(),
        new MiniCssExtractPlugin({
            filename: "[name].css"
    module: {
        rules: [{
            test: /\.scss$/,
            use: [


<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>{{ this.title }} &middot; {{ }} </title>

    <% for (var css in htmlWebpackPlugin.files.css) { %>
    <link href="{{ '/generated/<%= htmlWebpackPlugin.files.css[css] %>' | asseturl }}" rel="stylesheet">
    <% } %>

        {% block content %}
        {% endblock content %}

    <% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
    <script src="{{ '/generated/<%= htmlWebpackPlugin.files.chunks[chunk].entry %>' | asseturl }}"></script>
    <% } %>


You can configure the following options via configs/webpack-html-helper.ini

parameter default value description
src_dir /assets The folder that gets recursively observed by the watchdog.
target_dir /templates/ Lektors template folder.
You can’t perform that action at this time.