An open API service indexing awesome lists of open source software.

https://github.com/oliverepper/lektor-webpack-html-helper

Automatically moves html-files from lektors assets folder into lektors templates folder.
https://github.com/oliverepper/lektor-webpack-html-helper

html-webpack-plugin lektor webpack4

Last synced: 3 months ago
JSON representation

Automatically moves html-files from lektors assets folder into lektors templates folder.

Awesome Lists containing this project

README

          

# lektor-webpack-html-helper
[![PyPI version](https://badge.fury.io/py/lektor-webpack-html-helper.svg)](https://badge.fury.io/py/lektor-webpack-html-helper)
[![Downloads](https://pepy.tech/badge/lektor-webpack-html-helper)](https://pepy.tech/project/lektor-webpack-html-helper)

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](https://github.com/lektor/lektor-webpack-support) plugin to be really useful.

# webpack/webpack.config.js
```js
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: [
MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader"
]
}]
}
}
```

# webpack/src/layout_template.html
```html




{{ this.title }} · {{ config.PROJECT.name }}

<% for (var css in htmlWebpackPlugin.files.css) { %>

<% } %>


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

<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>

<% } %>

```

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. |