Skip to content

Compiled template classes preserve whitespace #12113

@royeden

Description

@royeden

Version

2.6.13

Reproduction link

https://codesandbox.io/s/dazzling-cache-q8y8o?file=/src/App.vue

Steps to reproduce

Add whitespace between classes, for example with the latest changes in prettier sorting classes into individual newlines, an they'll end up with whitespace on production builds.

Example:

Template.vue:

<template>
  <div
    class="
      flex
      items-center
      w-full
      px-5
      py-3
      text-sm
      transition-colors
      duration-300
      ease-in-out
      focus:outline-none
      text-opacity-80
    "
  >
    <slot></slot>
  </div>
</template>

<script>
export default {}
</script>

Will be compiled to this

("div", { staticClass:"\n    flex\n    items-center\n    w-full\n    px-5\n    py-3\n    text-sm\n    transition-colors\n    duration-300\n    ease-in-out\n    focus:outline-none\n    text-opacity-80\n  "}, /* rest of the code */)

This happens regardless of whitespace preservation options in the compiler

What is expected?

Expected class names to be trimmed of whitespace during production builds.

What is actually happening?

Whitespace isn't trimmed in class names after compilation of templates.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions