generated from Seekra/repository-template
feat(legal): minify imprint HTML when building
This commit is contained in:
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { minify } from 'html-minifier-terser';
|
||||||
import MarkdownIt from 'markdown-it';
|
import MarkdownIt from 'markdown-it';
|
||||||
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
||||||
|
|
||||||
@@ -23,6 +24,12 @@ export default async function build () {
|
|||||||
const imprintMd = await readFile('./src/legal/imprint.md', { encoding: 'utf-8' });
|
const imprintMd = await readFile('./src/legal/imprint.md', { encoding: 'utf-8' });
|
||||||
const imprintHtml = md.render(imprintMd);
|
const imprintHtml = md.render(imprintMd);
|
||||||
|
|
||||||
|
const imprintHtmlMinified = await minify(imprintHtml, {
|
||||||
|
collapseWhitespace: true,
|
||||||
|
collapseInlineTagWhitespace: true,
|
||||||
|
removeComments: true
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
artifacts: [
|
artifacts: [
|
||||||
{
|
{
|
||||||
@@ -30,7 +37,7 @@ export default async function build () {
|
|||||||
path: 'legal/imprint.html',
|
path: 'legal/imprint.html',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
options: {
|
options: {
|
||||||
content: imprintHtml,
|
content: imprintHtmlMinified,
|
||||||
encoding: 'utf-8'
|
encoding: 'utf-8'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user