Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
feat: WebIndexPlugin additional attributes support in script tags (#1246
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lanceschi authored and nchanged committed May 3, 2018
1 parent fcfbfa0 commit f790bfb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/plugins/html/WebIndexPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ fuse.plugin(
| ` resolve ` | `resolve ?: {(output : UserOutput) : string}` Allows to completely override the output |
| `pre ` | `{ relType: 'fetch' | 'load' }` Config object to either preload or prefetch the output javascript bundles in the head of the document |
| ` appendBundles ` | Append $bundles to provided template |
| ` async ` | Provide `async` attribute to `<script>` tags (boolena) |
| ` scriptAttributes ` | Provide additional attribute(s) to `<script>` tags (string) |

note: If you specify template and templateString then template will take precedent

note: If you specify template and templateString then template will take precedent

### Resolve example
`resolve` option allows you to completely override the path
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/WebIndexPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface IndexPluginOptions {
templateString?: string;
appendBundles?: boolean;
async?: boolean;
scriptAttributes?: string;
pre?: { relType: 'fetch' | 'load' };
resolve?: { (output: UserOutput): string };
emitBundles?: (bundles: string[]) => string;
Expand Down Expand Up @@ -86,7 +87,7 @@ $bundles

let jsTags = this.opts.emitBundles
? this.opts.emitBundles(bundlePaths)
: bundlePaths.map(bundle => `<script ${this.opts.async ? 'async' : ''} type="text/javascript" src="${bundle}"></script>`).join('\n');
: bundlePaths.map(bundle => `<script ${this.opts.async ? 'async' : ''} ${this.opts.scriptAttributes ? this.opts.scriptAttributes : ''} type="text/javascript" src="${bundle}"></script>`).join('\n');

let preloadTags;
if (this.opts.pre) {
Expand Down

0 comments on commit f790bfb

Please sign in to comment.