From 2d60a92e3a5a8be5502b1efd0af2c28664c34c51 Mon Sep 17 00:00:00 2001 From: dfritschy Date: Fri, 11 Jun 2021 17:17:23 +0200 Subject: [PATCH] feat: add posthtml plugin to include html fragments --- package-lock.json | 386 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 4 +- vite.config.js | 15 +- 3 files changed, 402 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1922d3f..137c37c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,10 @@ "devDependencies": { "autoprefixer": "^10.2.5", "postcss": "^8.2.15", + "posthtml-include": "^1.7.1", "sass": "^1.33.0", - "vite": "^2.3.3" + "vite": "^2.3.3", + "vite-plugin-posthtml": "^0.0.2" } }, "node_modules/anymatch": { @@ -135,12 +137,76 @@ "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==", "dev": true }, + "node_modules/dom-serializer": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", + "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "dev": true, + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz", + "integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==", + "dev": true, + "dependencies": { + "domelementtype": "^2.2.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz", + "integrity": "sha512-8eaHa17IwJUPAiB+SoTYBo5mCdeMgdcAoXJ59m6DT1vw+5iLS3gNoqYaRowaBKtGVrOF1Jz4yDTgYKLK2kvfJg==", + "dev": true, + "dependencies": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, "node_modules/electron-to-chromium": { "version": "1.3.734", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.734.tgz", "integrity": "sha512-iQF2mjPZ6zNNq45kbJ6MYZYCBNdv2JpGiJC/lVx4tGJWi9MNg73KkL9sWGN4X4I/CP2SBLWsT8nPADZZpAHIyw==", "dev": true }, + "node_modules/entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/esbuild": { "version": "0.11.23", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.11.23.tgz", @@ -160,6 +226,12 @@ "node": ">=6" } }, + "node_modules/fclone": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/fclone/-/fclone-1.0.11.tgz", + "integrity": "sha1-EOhdo4v+p/xZk0HClu4ddyZu5kA=", + "dev": true + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -225,6 +297,25 @@ "node": ">= 0.4.0" } }, + "node_modules/htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -357,6 +448,114 @@ "integrity": "sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==", "dev": true }, + "node_modules/posthtml-expressions": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/posthtml-expressions/-/posthtml-expressions-1.7.1.tgz", + "integrity": "sha512-OtshMi4yJO/KAUSzLOdhWPaffPApY3lXZpJKzu4jVHfO7b8/a26Hgsl/cjC6PGtpyDEHbYChnV/b4DbIUoVREw==", + "dev": true, + "dependencies": { + "fclone": "^1.0.11", + "posthtml-parser": "^0.6.0", + "posthtml-render": "^1.4.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/posthtml-expressions/node_modules/domhandler": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-3.3.0.tgz", + "integrity": "sha512-J1C5rIANUbuYK+FuFL98650rihynUOEzRLxW+90bKZRWB6A1X1Tf82GxR1qAWLyfNPRvjqfip3Q5tdYlmAa9lA==", + "dev": true, + "dependencies": { + "domelementtype": "^2.0.1" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/posthtml-expressions/node_modules/htmlparser2": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-5.0.1.tgz", + "integrity": "sha512-vKZZra6CSe9qsJzh0BjBGXo8dvzNsq/oGvsjfRdOrrryfeD9UOBEEQdeoqCRmKZchF5h2zOBMQ6YuQ0uRUmdbQ==", + "dev": true, + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^3.3.0", + "domutils": "^2.4.2", + "entities": "^2.0.0" + }, + "funding": { + "url": "https://github.com/fb55/htmlparser2?sponsor=1" + } + }, + "node_modules/posthtml-expressions/node_modules/posthtml-parser": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/posthtml-parser/-/posthtml-parser-0.6.0.tgz", + "integrity": "sha512-5ffwKQNgtVHdhZniWxu+1ryvaZv5l25HPLUV6W5xy5nYVWMXtvjtwRnbSpfbKFvbyl7XI+d4AqkjmonkREqnXA==", + "dev": true, + "dependencies": { + "htmlparser2": "^5.0.1" + }, + "engines": { + "node": ">=10.0.0" + }, + "funding": { + "type": "patreon", + "url": "https://opencollective.com/posthtml" + } + }, + "node_modules/posthtml-include": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/posthtml-include/-/posthtml-include-1.7.1.tgz", + "integrity": "sha512-T/vE9JUPWtLRvi3W/tX9KQNL3j24FbxqpM1ftyhnB+YX5HBx607I5SNnFC6UAnxw5aBIC2M5LWgMpqCesoI8xA==", + "dev": true, + "dependencies": { + "posthtml": "^0.15.1", + "posthtml-expressions": "^1.7.1", + "posthtml-parser": "^0.7.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/posthtml-include/node_modules/posthtml": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/posthtml/-/posthtml-0.15.2.tgz", + "integrity": "sha512-YugEJ5ze/0DLRIVBjCpDwANWL4pPj1kHJ/2llY8xuInr0nbkon3qTiMPe5LQa+cCwNjxS7nAZZTp+1M+6mT4Zg==", + "dev": true, + "dependencies": { + "posthtml-parser": "^0.7.2", + "posthtml-render": "^1.3.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/posthtml-parser": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/posthtml-parser/-/posthtml-parser-0.7.2.tgz", + "integrity": "sha512-LjEEG/3fNcWZtBfsOE3Gbyg1Li4CmsZRkH1UmbMR7nKdMXVMYI3B4/ZMiCpaq8aI1Aym4FRMMW9SAOLSwOnNsQ==", + "dev": true, + "dependencies": { + "htmlparser2": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/posthtml-render": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/posthtml-render/-/posthtml-render-1.4.0.tgz", + "integrity": "sha512-W1779iVHGfq0Fvh2PROhCe2QhB8mEErgqzo1wpIt36tCgChafP+hbXIhLDOM8ePJrZcFs0vkNEtdibEWVqChqw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/readdirp": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", @@ -453,6 +652,28 @@ "optionalDependencies": { "fsevents": "~2.3.1" } + }, + "node_modules/vite-plugin-posthtml": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/vite-plugin-posthtml/-/vite-plugin-posthtml-0.0.2.tgz", + "integrity": "sha512-QYibaPSL4IgFk9h4Vkt3Xf6OVK5lyPwseKv1j6YxQNxJDcwmjw+7oH0x1Y9UwAHWGZOaZ85PKhqZPiZsl9dGQA==", + "dev": true, + "dependencies": { + "posthtml": "^0.15.2" + } + }, + "node_modules/vite-plugin-posthtml/node_modules/posthtml": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/posthtml/-/posthtml-0.15.2.tgz", + "integrity": "sha512-YugEJ5ze/0DLRIVBjCpDwANWL4pPj1kHJ/2llY8xuInr0nbkon3qTiMPe5LQa+cCwNjxS7nAZZTp+1M+6mT4Zg==", + "dev": true, + "dependencies": { + "posthtml-parser": "^0.7.2", + "posthtml-render": "^1.3.1" + }, + "engines": { + "node": ">=10.0.0" + } } }, "dependencies": { @@ -536,12 +757,55 @@ "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==", "dev": true }, + "dom-serializer": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", + "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + } + }, + "domelementtype": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", + "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "dev": true + }, + "domhandler": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.0.tgz", + "integrity": "sha512-zk7sgt970kzPks2Bf+dwT/PLzghLnsivb9CcxkvR8Mzr66Olr0Ofd8neSbglHJHaHa2MadfoSdNlKYAaafmWfA==", + "dev": true, + "requires": { + "domelementtype": "^2.2.0" + } + }, + "domutils": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.7.0.tgz", + "integrity": "sha512-8eaHa17IwJUPAiB+SoTYBo5mCdeMgdcAoXJ59m6DT1vw+5iLS3gNoqYaRowaBKtGVrOF1Jz4yDTgYKLK2kvfJg==", + "dev": true, + "requires": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + } + }, "electron-to-chromium": { "version": "1.3.734", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.734.tgz", "integrity": "sha512-iQF2mjPZ6zNNq45kbJ6MYZYCBNdv2JpGiJC/lVx4tGJWi9MNg73KkL9sWGN4X4I/CP2SBLWsT8nPADZZpAHIyw==", "dev": true }, + "entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true + }, "esbuild": { "version": "0.11.23", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.11.23.tgz", @@ -554,6 +818,12 @@ "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", "dev": true }, + "fclone": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/fclone/-/fclone-1.0.11.tgz", + "integrity": "sha1-EOhdo4v+p/xZk0HClu4ddyZu5kA=", + "dev": true + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -600,6 +870,18 @@ "function-bind": "^1.1.1" } }, + "htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, "is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -692,6 +974,87 @@ "integrity": "sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==", "dev": true }, + "posthtml-expressions": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/posthtml-expressions/-/posthtml-expressions-1.7.1.tgz", + "integrity": "sha512-OtshMi4yJO/KAUSzLOdhWPaffPApY3lXZpJKzu4jVHfO7b8/a26Hgsl/cjC6PGtpyDEHbYChnV/b4DbIUoVREw==", + "dev": true, + "requires": { + "fclone": "^1.0.11", + "posthtml-parser": "^0.6.0", + "posthtml-render": "^1.4.0" + }, + "dependencies": { + "domhandler": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-3.3.0.tgz", + "integrity": "sha512-J1C5rIANUbuYK+FuFL98650rihynUOEzRLxW+90bKZRWB6A1X1Tf82GxR1qAWLyfNPRvjqfip3Q5tdYlmAa9lA==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1" + } + }, + "htmlparser2": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-5.0.1.tgz", + "integrity": "sha512-vKZZra6CSe9qsJzh0BjBGXo8dvzNsq/oGvsjfRdOrrryfeD9UOBEEQdeoqCRmKZchF5h2zOBMQ6YuQ0uRUmdbQ==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^3.3.0", + "domutils": "^2.4.2", + "entities": "^2.0.0" + } + }, + "posthtml-parser": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/posthtml-parser/-/posthtml-parser-0.6.0.tgz", + "integrity": "sha512-5ffwKQNgtVHdhZniWxu+1ryvaZv5l25HPLUV6W5xy5nYVWMXtvjtwRnbSpfbKFvbyl7XI+d4AqkjmonkREqnXA==", + "dev": true, + "requires": { + "htmlparser2": "^5.0.1" + } + } + } + }, + "posthtml-include": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/posthtml-include/-/posthtml-include-1.7.1.tgz", + "integrity": "sha512-T/vE9JUPWtLRvi3W/tX9KQNL3j24FbxqpM1ftyhnB+YX5HBx607I5SNnFC6UAnxw5aBIC2M5LWgMpqCesoI8xA==", + "dev": true, + "requires": { + "posthtml": "^0.15.1", + "posthtml-expressions": "^1.7.1", + "posthtml-parser": "^0.7.1" + }, + "dependencies": { + "posthtml": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/posthtml/-/posthtml-0.15.2.tgz", + "integrity": "sha512-YugEJ5ze/0DLRIVBjCpDwANWL4pPj1kHJ/2llY8xuInr0nbkon3qTiMPe5LQa+cCwNjxS7nAZZTp+1M+6mT4Zg==", + "dev": true, + "requires": { + "posthtml-parser": "^0.7.2", + "posthtml-render": "^1.3.1" + } + } + } + }, + "posthtml-parser": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/posthtml-parser/-/posthtml-parser-0.7.2.tgz", + "integrity": "sha512-LjEEG/3fNcWZtBfsOE3Gbyg1Li4CmsZRkH1UmbMR7nKdMXVMYI3B4/ZMiCpaq8aI1Aym4FRMMW9SAOLSwOnNsQ==", + "dev": true, + "requires": { + "htmlparser2": "^6.0.0" + } + }, + "posthtml-render": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/posthtml-render/-/posthtml-render-1.4.0.tgz", + "integrity": "sha512-W1779iVHGfq0Fvh2PROhCe2QhB8mEErgqzo1wpIt36tCgChafP+hbXIhLDOM8ePJrZcFs0vkNEtdibEWVqChqw==", + "dev": true + }, "readdirp": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", @@ -756,6 +1119,27 @@ "resolve": "^1.19.0", "rollup": "^2.38.5" } + }, + "vite-plugin-posthtml": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/vite-plugin-posthtml/-/vite-plugin-posthtml-0.0.2.tgz", + "integrity": "sha512-QYibaPSL4IgFk9h4Vkt3Xf6OVK5lyPwseKv1j6YxQNxJDcwmjw+7oH0x1Y9UwAHWGZOaZ85PKhqZPiZsl9dGQA==", + "dev": true, + "requires": { + "posthtml": "^0.15.2" + }, + "dependencies": { + "posthtml": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/posthtml/-/posthtml-0.15.2.tgz", + "integrity": "sha512-YugEJ5ze/0DLRIVBjCpDwANWL4pPj1kHJ/2llY8xuInr0nbkon3qTiMPe5LQa+cCwNjxS7nAZZTp+1M+6mT4Zg==", + "dev": true, + "requires": { + "posthtml-parser": "^0.7.2", + "posthtml-render": "^1.3.1" + } + } + } } } } diff --git a/package.json b/package.json index c2bfd66..489ebbe 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,9 @@ "devDependencies": { "autoprefixer": "^10.2.5", "postcss": "^8.2.15", + "posthtml-include": "^1.7.1", "sass": "^1.33.0", - "vite": "^2.3.3" + "vite": "^2.3.3", + "vite-plugin-posthtml": "^0.0.2" } } diff --git a/vite.config.js b/vite.config.js index bcd5098..3ba5194 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,6 +1,8 @@ // vite.config.js const { resolve } = require('path') +const { posthtmlPlugin } = require('vite-plugin-posthtml'); +// https://github.com/chromeos/static-site-scaffold-modules/tree/main/modules/vite-plugin-posthtml export default { root: "./src", @@ -11,8 +13,19 @@ export default { de_index: resolve(__dirname, 'src/index.html'), de_contact: resolve(__dirname, 'src/contact.html'), de_data: resolve(__dirname, 'src/impress.html'), - en: resolve(__dirname, 'src/en/index.html') + en_index: resolve(__dirname, 'src/en/index.html'), + en_contact: resolve(__dirname, 'src/en/contact.html'), + en_data: resolve(__dirname, 'src/en/impress.html'), } } }, + plugins: [ + posthtmlPlugin({ + plugins: [ + require('posthtml-include')(), + //require('posthtml-favicons')() + ], + options: {} + }) + ] }