glorious-codes / glorious-pitsby

Docs generator for AngularJS, Vue, React, and Vanilla components.
https://pitsby.compilorama.com
MIT License
90 stars 7 forks source link

Add ability to set attributes for external assets html tags #224

Closed rafaelcamargo closed 2 years ago

rafaelcamargo commented 2 years ago

Ref.: https://github.com/glorious-codes/glorious-pitsby/issues/223

This Pull Request introduces the necessary changes to allow Pitsby users to set attributes to the generated HTML tags that will import Styles and Scripts set in Pitsby configuration file.

At this moment, users are limited to set a script src or a stylesheet href. With these new changes, users will be able to pass HTML attributes other than just src or href. See below:

// pitsby.config.js

module.exports = {

  // Current API
  styles: ['./dist/components.css', './dist/other.css'],
  scripts: ['./dist/components.js', './dist/custom.js', 'https://some.cdn.com/lib.js', './other.js']

  // Proposed API
  styles: [
    { rel: 'prefetch', href: './dist/other.css', as: 'style' },
    './dist/components.css'
  ],
  scripts: [
    { rel: 'preload', href: './dist/custom.js', as: 'script' },
    { type: 'module', src: './dist/components.js' },
    { crossorigin: '', src: 'https://some.cdn.com/lib.js' },
    './other.js'
  ]
}