Forráskód Böngészése

fear: nuxt ^2.00 版本后,webpack HtmlWebpackPlguin插件打包 会存在htlm5不能转换的问题

shenjunjie 7 éve
szülő
commit
4b633f159f
1 módosított fájl, 13 hozzáadás és 26 törlés
  1. 13 26
      nuxt.config.js

+ 13 - 26
nuxt.config.js

@@ -69,34 +69,21 @@ module.exports = {
         '~plugins': path.join(__dirname, 'plugins'),
         '~store': path.join(__dirname, 'store')
       })
-      if (config.plugins[4] && config.plugins[4].options && config.plugins[4].options.minify) {
-        config.plugins[4].options.minify = {
-          removeAttributeQuotes: true,
-          collapseWhitespace: true,
-          html5: true,
-          minifyCSS: true,
-          removeComments: true,
-          removeEmptyAttributes: true,
-        }
-      }
-      if (config.plugins[5] && config.plugins[5].options && config.plugins[5].options.minify) {
-        config.plugins[5].options.minify = {
-          removeAttributeQuotes: true,
-          collapseWhitespace: true,
-          html5: true,
-          minifyCSS: true,
-          removeComments: true,
-          removeEmptyAttributes: true,
+
+      // nuxt ^2.00 版本后,webpack HtmlWebpackPlguin插件打包 会存在htlm5不能转换的问题
+      // 已经命令是将 该插件 压缩部分进行重新处理
+      for (let i = 0; i < config.plugins.length; i++) {
+        if (config.plugins[i] && config.plugins[i].options && config.plugins[i].options.minify) {
+          config.plugins[i].options.minify = {
+            removeAttributeQuotes: true,
+            collapseWhitespace: true,
+            html5: true,
+            minifyCSS: true,
+            removeComments: true,
+            removeEmptyAttributes: true,
+          }
         }
       }
-      // config.plugins.push(new HtmlWebpackPlugin({
-      //   title: 'React Title !',
-      //   template: './app.html',
-      //   minify: {
-      //     removeAttributeQuotes: true
-      //   },
-      //   inject: 'body'
-      // }))
       // config.resolve.alias['~utils'] = path.join(__dirname, 'utils')
       // config.resolve.alias['~components'] = path.join(__dirname, 'components')
       // config.resolve.alias['assets'] = path.join(__dirname, './assets')