nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

I am unable to access html.minify options for Nuxt.js in order to NOT minify the HTML output in run generate

Open xdcha opened this issue 1 year ago • 0 comments

I'm trying, when running npm run generate to not minify the HTML.

Even though it's deprecated:

generate: {
    minify:false
} 

..does indeed minify the CSS. This isn't what I'm after though.

The docs say to use html.minify now:

{
  collapseBooleanAttributes: true,
  decodeEntities: true,
  minifyCSS: true,
  minifyJS: true,
  processConditionalComments: true,
  removeEmptyAttributes: true,
  removeRedundantAttributes: true,
  trimCustomFragments: true,
  useShortDoctype: true
}

These look like the presets but even if you change minifyCSS to false there is still no change in the output to the dist folder after running generate.

Am I at all able to not compress/minify the HTML and to instead have it formatted nicely when I run npm run generate.

My nuxt.config.js

export default {
  // Target: https://go.nuxtjs.dev/config-target
  target: 'static',

  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'frontend-tw-build-test',
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    '@/assets/css/main.css',
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/tailwindcss
    '@nuxtjs/tailwindcss',
    '@nuxt/postcss8'
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
  ],

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    postcss: {
      plugins: {
        tailwindcss: {},
        autoprefixer: {},
      },
    },
  },

  html: {
    minify: {
      collapseBooleanAttributes: true,
      collapseInlineTagWhitespace: false,
      collapseWhitespac: false,
      decodeEntities: true,
      minifyCSS: false,
      minifyJS: false,
      processConditionalComments: true,
      removeEmptyAttributes: true,
      removeRedundantAttributes: true,
      trimCustomFragments: true,
      useShortDoctype: true
    }
  }


}

Am I missing something blindingly obvious here?

xdcha avatar Aug 25 '22 16:08 xdcha