web icon indicating copy to clipboard operation
web copied to clipboard

feat(rollup-plugin-html): extractAssets from custom tagName

Open gdbaldw opened this issue 4 years ago • 1 comments

Optional array of tagName and attribute objects, useful for extracting assets from custom tags

What I did

-1. Fixed latent issues with existing demos, and added a line to Developer Doc

  1. Created new test case: src/input/extract/extractAssetsByTagAndAttributes.test.ts
  2. Created a new interface for TagAndAttribute
  3. Enhanced extractAssets interface to: boolean | TagAndAttribute[]
  4. Injected extractAssets into the relevant asset/utils.ts functions
  5. All relevant function signatures optionally include params.extractAssets
  6. Passed all tests
  7. Updated demo/spa to demonstrate TagAndAttribute[]
  8. Linted and Formatted
  9. Updated documentation to show how to use this new feature
  10. Added demo/disable to demonstrate that extractAssets: false still works correctly
  11. Added support for recursive templates, then re-test, re-lint, and re-format.

Example usage

const html = require('../../dist/index').default;

module.exports = {
  input: 'demo/spa/index.html',
  output: {
    dir: './demo/dist',
  },
  plugins: [html({
    absoluteBaseUrl: 'http://localhost:8000',
    extractAssets: [
      {tagName: 'my-first-el', attribute: 'my-src'},
      {tagName: 'my-second-el', attribute: 'my-src'},
    ]
  })],
};

gdbaldw avatar Jul 04 '21 14:07 gdbaldw

⚠️ No Changeset found

Latest commit: 7201bf70c2a87131c2e3bc8e6b1bd6a36fbdfbd6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 04 '21 14:07 changeset-bot[bot]