[\s\S]*?<\/code>/],
+ minifyCSS: true,
+ minifyJS: true,
+ removeComments: true,
+ removeScriptTypeAttributes: true,
+ removeStyleLinkTypeAttributes: true,
+};
function composePage(url) {
const { title, contents } = JSON.parse(fs.readFileSync(`./dist/generated/docs/${url}.json`, 'utf-8'));
@@ -25,7 +31,7 @@ function composePage(url) {
.replace('Angular Docs ', `${title} - Angular 官方文档 `)
.replace(' ', ssrContent);
mkdirp.sync(path.dirname(`./dist/${url}`));
- fs.writeFileSync(`./dist/${url}.html`, purge(pageContent), 'utf-8');
+ fs.writeFileSync(`./dist/${url}.html`, minify(pageContent, minifyOptions), 'utf-8');
}
function buildGuidePages(): void {
@@ -45,14 +51,14 @@ function buildApiPages(): void {
const apiListContent = fs.readFileSync('./dist/api.html', 'utf-8')
.replace(rootElementPattern, `API List
${links} `);
- fs.writeFileSync(`./dist/api.html`, purge(apiListContent), 'utf-8');
+ fs.writeFileSync(`./dist/api.html`, minify(apiListContent, minifyOptions), 'utf-8');
}
function buildIndexPage(): void {
const indexTemplate = fs.readFileSync('./dist/index.html', 'utf-8');
const aioShellIndex = fs.readFileSync(__dirname + '/../assets/aio-shell-index.html');
const content = indexTemplate.replace(rootElementPattern, `${aioShellIndex}`);
- fs.writeFileSync(`./dist/index.html`, purge(content), 'utf-8');
+ fs.writeFileSync(`./dist/index.html`, minify(content, minifyOptions), 'utf-8');
}
buildGuidePages();
diff --git a/aio/yarn.lock b/aio/yarn.lock
index 844145fb44..d1958db2a8 100644
--- a/aio/yarn.lock
+++ b/aio/yarn.lock
@@ -2214,6 +2214,12 @@ clean-css@4.1.x, clean-css@^4.1.11:
dependencies:
source-map "0.5.x"
+clean-css@4.2.x:
+ version "4.2.1"
+ resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-4.2.1.tgz#2d411ef76b8569b6d0c84068dabe85b0aa5e5c17"
+ dependencies:
+ source-map "~0.6.0"
+
cli-boxes@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143"
@@ -2409,6 +2415,10 @@ commander@2.15.x, commander@^2.12.1, commander@^2.9.0, commander@~2.15.0:
version "2.15.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
+commander@2.17.x, commander@~2.17.1:
+ version "2.17.1"
+ resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
+
commander@2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.6.0.tgz#9df7e52fb2a0cb0fb89058ee80c3104225f37e1d"
@@ -5028,6 +5038,18 @@ html-minifier@^3.2.3:
relateurl "0.2.x"
uglify-js "3.3.x"
+html-minifier@^3.5.20:
+ version "3.5.20"
+ resolved "https://registry.yarnpkg.com/html-minifier/-/html-minifier-3.5.20.tgz#7b19fd3caa0cb79f7cde5ee5c3abdf8ecaa6bb14"
+ dependencies:
+ camel-case "3.0.x"
+ clean-css "4.2.x"
+ commander "2.17.x"
+ he "1.1.x"
+ param-case "2.1.x"
+ relateurl "0.2.x"
+ uglify-js "3.4.x"
+
html-void-elements@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/html-void-elements/-/html-void-elements-1.0.2.tgz#9d22e0ca32acc95b3f45b8d5b4f6fbdc05affd55"
@@ -9487,7 +9509,7 @@ source-map@^0.4.2, source-map@^0.4.4, source-map@~0.4.1:
dependencies:
amdefine ">=0.0.4"
-source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
+source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
@@ -10341,6 +10363,13 @@ uglify-js@3.3.x:
commander "~2.15.0"
source-map "~0.6.1"
+uglify-js@3.4.x:
+ version "3.4.9"
+ resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"
+ dependencies:
+ commander "~2.17.1"
+ source-map "~0.6.1"
+
uglify-js@^2.6:
version "2.8.29"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"