From 99137d0895e2ee3f1694fdd4d074b7103337342c Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 23 Sep 2020 20:17:19 +0800 Subject: [PATCH 1/2] fix: shouldn't remove attribute quotes in HTML Fixes #5896 It's also recommended to enable this option with caution in the html-minifier documentation: --- packages/@vue/cli-service/lib/config/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/@vue/cli-service/lib/config/app.js b/packages/@vue/cli-service/lib/config/app.js index f940b4ad8c..08f4346806 100644 --- a/packages/@vue/cli-service/lib/config/app.js +++ b/packages/@vue/cli-service/lib/config/app.js @@ -121,7 +121,6 @@ module.exports = (api, options) => { minify: { removeComments: true, collapseWhitespace: true, - removeAttributeQuotes: true, collapseBooleanAttributes: true, removeScriptTypeAttributes: true // more options: From 641ec1be83367e6ebee5917e84b082de777fced9 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 24 Sep 2020 15:02:22 +0800 Subject: [PATCH 2/2] test: update corresponding tests for attribute quotes --- .../__tests__/pwaPlugin.spec.js | 10 +-- .../@vue/cli-service/__tests__/build.spec.js | 14 ++-- .../@vue/cli-service/__tests__/cors.spec.js | 6 +- .../cli-service/__tests__/modernMode.spec.js | 28 ++++---- .../cli-service/__tests__/multiPage.spec.js | 68 +++++++++---------- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js b/packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js index 070be9e4a7..1f349b9416 100644 --- a/packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js +++ b/packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js @@ -30,16 +30,16 @@ test('pwa', async () => { const index = await project.read('dist/index.html') // should split and preload app.js & vendor.js - expect(index).toMatch(/]+js\/app[^>]+\.js rel=preload as=script>/) - expect(index).toMatch(/]+js\/chunk-vendors[^>]+\.js rel=preload as=script>/) + expect(index).toMatch(/]+js\/app[^>]+\.js" rel="preload" as="script">/) + expect(index).toMatch(/]+js\/chunk-vendors[^>]+\.js" rel="preload" as="script">/) // should preload css - expect(index).toMatch(/]+app[^>]+\.css rel=preload as=style>/) + expect(index).toMatch(/]+app[^>]+\.css" rel="preload" as="style">/) // PWA specific directives - expect(index).toMatch(``) + expect(index).toMatch(``) // favicon is not minified because it's technically a comment expect(index).toMatch(``) - expect(index).toMatch(``) + expect(index).toMatch(``) // should import service worker script const main = await project.read('src/main.js') diff --git a/packages/@vue/cli-service/__tests__/build.spec.js b/packages/@vue/cli-service/__tests__/build.spec.js index 070d29a559..85948f1217 100644 --- a/packages/@vue/cli-service/__tests__/build.spec.js +++ b/packages/@vue/cli-service/__tests__/build.spec.js @@ -28,19 +28,19 @@ test('build', async () => { const index = await project.read('dist/index.html') // should split and preload app.js & vendor.js - expect(index).toMatch(/]+js\/app[^>]+\.js rel=preload as=script>/) - expect(index).toMatch(/]+js\/chunk-vendors[^>]+\.js rel=preload as=script>/) + expect(index).toMatch(/]+js\/app[^>]+\.js" rel="preload" as="script">/) + expect(index).toMatch(/]+js\/chunk-vendors[^>]+\.js" rel="preload" as="script">/) // should preload css - expect(index).toMatch(/]+app[^>]+\.css rel=preload as=style>/) + expect(index).toMatch(/]+app[^>]+\.css" rel="preload" as="style">/) // should inject scripts - expect(index).toMatch(/