This repository has been archived by the owner on Jan 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
194 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { minify } = require('html-minifier') | ||
|
||
const defaultOptions = { | ||
collapseWhitespace: true, | ||
removeRedundantAttributes: true, | ||
removeScriptTypeAttributes: true, | ||
removeStyleLinkTypeAttributes: true, | ||
useShortDoctype: true, | ||
minifyCSS: true | ||
} | ||
|
||
module.exports = (html, options) => | ||
minify(html, options === true ? defaultOptions : options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
tap-snapshots/test-projects-html-minifier-index.test.js-TAP.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* IMPORTANT | ||
* This snapshot file is auto-generated, but designed for humans. | ||
* It should be checked into source control and tracked carefully. | ||
* Re-generate by setting TAP_SNAPSHOT=1 and running tests. | ||
* Make sure to inspect the output below. Do not ignore changes! | ||
*/ | ||
'use strict' | ||
exports[`test/projects/html-minifier/index.test.js TAP test/projects/html-minifier > page 1`] = ` | ||
<!DOCTYPE html><html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui" /> | ||
<title data-ream-head="true"></title> | ||
<link rel="preload" href="/_ream/chunk-vendors.js" as="script"><link rel="preload" href="/_ream/client.js" as="script"><link rel="prefetch" href="/_ream/chunk--base-pages-index.js"><style data-vue-ssr-id="234417f0:0"> | ||
.test { | ||
color: black | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="_ream" data-server-rendered="true"><div class="test"> | ||
Test | ||
</div></div> | ||
<script>window.__REAM__={"initialData":{}}</script><script src="/_ream/chunk-vendors.js" defer></script><script src="/_ream/client.js" defer></script> | ||
</body> | ||
</html> | ||
` | ||
|
||
exports[`test/projects/html-minifier/index.test.js TAP test/projects/html-minifier > page 2`] = ` | ||
<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,minimal-ui"><title data-ream-head="true"></title><link rel="preload" href="/_ream/chunk-vendors.js" as="script"><link rel="preload" href="/_ream/client.js" as="script"><link rel="prefetch" href="/_ream/chunk--base-pages-index.js"><style data-vue-ssr-id="234417f0:0">.test{color:#000}</style></head><body><div id="_ream" data-server-rendered="true"><div class="test">Test</div></div><script>window.__REAM__={"initialData":{}}</script><script src="/_ream/chunk-vendors.js" defer="defer"></script><script src="/_ream/client.js" defer="defer"></script></body></html> | ||
` | ||
|
||
exports[`test/projects/html-minifier/index.test.js TAP test/projects/html-minifier > page 3`] = ` | ||
<!DOCTYPE html><html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,minimal-ui"> | ||
<title data-ream-head="true"></title> | ||
<link rel="preload" href="/_ream/chunk-vendors.js" as="script"><link rel="preload" href="/_ream/client.js" as="script"><link rel="prefetch" href="/_ream/chunk--base-pages-index.js"><style data-vue-ssr-id="234417f0:0">.test{color:#000}</style> | ||
</head> | ||
<body> | ||
<div id="_ream" data-server-rendered="true"><div class="test"> | ||
Test | ||
</div></div> | ||
<script>window.__REAM__={"initialData":{}}</script><script src="/_ream/chunk-vendors.js" defer="defer"></script><script src="/_ream/client.js" defer="defer"></script> | ||
</body> | ||
</html> | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const testProject = require('../../lib/testProject') | ||
|
||
const configs = [ | ||
{ | ||
minifyHtml: false | ||
}, | ||
{ | ||
minifyHtml: true | ||
}, | ||
{ | ||
minifyHtml: { | ||
minifyCSS: true | ||
} | ||
} | ||
] | ||
|
||
for (const config of configs) { | ||
testProject( | ||
__dirname, | ||
async (t, c) => { | ||
t.matchSnapshot((await c.axios.get('/')).data, 'page') | ||
}, | ||
config | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div class="test"> | ||
Test | ||
</div> | ||
</template> | ||
|
||
<style> | ||
.test { | ||
color: black | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
fsRoutes: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters