Static 如何在一行numxt.js中缩小HTML代码?

Static 如何在一行numxt.js中缩小HTML代码?,static,nuxt.js,minify,Static,Nuxt.js,Minify,我想知道是否可以在Nuxt.js中将页面源代码缩小到一行?不确定是否可以将其缩小到一行,但您肯定可以对HTML进行一些缩小。查看文档的这一部分: 根据作者的说法,nuxt使用的是隐藏的,而且似乎有很多缩小选项可供选择。不确定是否可以将其缩小到一行,但您肯定可以对HTML进行一些缩小。查看文档的这一部分: 根据作者的说法,nuxt使用的是引擎盖下,似乎有很多缩小选项可供选择。我认为nuxt已经缩小了hmtl本身。在中了解更多信息 如果要缩小css和js,请在nuxt.config.js中尝试此

我想知道是否可以在Nuxt.js中将页面源代码缩小到一行?

不确定是否可以将其缩小到一行,但您肯定可以对HTML进行一些缩小。查看文档的这一部分:


根据作者的说法,nuxt使用的是隐藏的,而且似乎有很多缩小选项可供选择。

不确定是否可以将其缩小到一行,但您肯定可以对HTML进行一些缩小。查看文档的这一部分:


根据作者的说法,nuxt使用的是引擎盖下,似乎有很多缩小选项可供选择。

我认为nuxt已经缩小了hmtl本身。在中了解更多信息

如果要缩小css和js,请在nuxt.config.js中尝试此选项:

build: {
    html:{
      minify:{
        collapseBooleanAttributes: true,
        decodeEntities: true,
        minifyCSS: true,
        minifyJS: true,
        processConditionalComments: true,
        removeEmptyAttributes: true,
        removeRedundantAttributes: true,
        trimCustomFragments: true,
        useShortDoctype: true,
        minifyURLs: true,
        removeComments: true,
        removeEmptyElements: true
      }
    }

我认为nuxt已经缩小了hmtl本身。在中了解更多信息

如果要缩小css和js,请在nuxt.config.js中尝试此选项:

build: {
    html:{
      minify:{
        collapseBooleanAttributes: true,
        decodeEntities: true,
        minifyCSS: true,
        minifyJS: true,
        processConditionalComments: true,
        removeEmptyAttributes: true,
        removeRedundantAttributes: true,
        trimCustomFragments: true,
        useShortDoctype: true,
        minifyURLs: true,
        removeComments: true,
        removeEmptyElements: true
      }
    }
这是朝着正确方向迈出的一步。要将页面源代码缩小到一行,还应添加:

  • 保留换行符:false
  • collapseWhitespace:true
注意下面代码段中build.html.minify下的最后两行

  build: {
    html: {
      minify: {
        collapseBooleanAttributes: true,
        decodeEntities: true,
        minifyCSS: true,
        minifyJS: true,
        processConditionalComments: true,
        removeEmptyAttributes: true,
        removeRedundantAttributes: true,
        trimCustomFragments: true,
        useShortDoctype: true,
        preserveLineBreaks: false,
        collapseWhitespace: true
      }
    },
 }
这是朝着正确方向迈出的一步。要将页面源代码缩小到一行,还应添加:

  • 保留换行符:false
  • collapseWhitespace:true
注意下面代码段中build.html.minify下的最后两行

  build: {
    html: {
      minify: {
        collapseBooleanAttributes: true,
        decodeEntities: true,
        minifyCSS: true,
        minifyJS: true,
        processConditionalComments: true,
        removeEmptyAttributes: true,
        removeRedundantAttributes: true,
        trimCustomFragments: true,
        useShortDoctype: true,
        preserveLineBreaks: false,
        collapseWhitespace: true
      }
    },
 }