Skip to content

PostHTML 0.16 regression with <style> #56

@ai

Description

@ai

Can’t add <style> in PostHTML 0.16 regression

Details

Custom plugin:

  let ignorePreload = { script: true, image: true }
  function htmlPlugin(tree) {
    tree.walk(i => {
      if (i.tag === 'link' && i.attrs.rel === 'stylesheet') {
        return [{ tag: 'style', content: [css] }]
      } else if (i.tag === 'link' && ignorePreload[i.attrs.as]) {
        return []
      } else if (i.tag === 'script') {
        return {
          tag: 'script',
          content: js
        }
      } else if (i.attrs && i.attrs.class) {
        return {
          tag: i.tag,
          content: i.content,
          attrs: {
            ...i.attrs,
            class: i.attrs.class
              .split(' ')
              .map(kls => {
                if (!classes[kls]) {
                  process.stderr.write(`Unused class .${kls}\n`)
                  process.exit(1)
                }
                return classes[kls]
              })
              .join(' ')
          }
        }
      } else {
        return i
      }
    })
  }

Error (Logs|Stacks)

No errors. Just lack of <style> compare to 0.15.

Reproduction (Code)

⚠️ Please remember that, with sample code; it's easier to reproduce a bug and much faster to fix it.

🔗 Please refer to a simple code example.

$ git clone https://github.com/ai/sitnik.ru
$ yarn build
$ cat ./dist/ru/index.html
# Has <style>
$ yarn upgrade-interactive --latest
# Update posthtml
$ yarn build
$ cat ./dist/ru/index.html
# No <style>

Environment

ℹ️ Please provide information about your current environment.

OS node npm/yarn package
Fedora 16.3 1.22.10 0.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions