import {ProjextRollupURLsPlugin} from 'projext-plugin-rollup/src/plugins/urls/index.js'
ProjextRollupURLsPlugin
This is a Rollup plugin that find files matching a filter, copy them and replace their code on the bundle with an export with a URL for the file.
Constructor Summary
Public Constructor | ||
public |
constructor(options: ProjextRollupURLsPluginOptions, name: string) |
Method Summary
Public Methods | ||
public |
Gets the plugin options |
|
public |
This is called by Rollup when a file is about to be loaded. |
|
public |
This is called by Rollup after it finishes writing the files on the file system. |
Public Constructors
public constructor(options: ProjextRollupURLsPluginOptions, name: string) source
Params:
Name | Type | Attribute | Description |
options | ProjextRollupURLsPluginOptions |
|
The options to customize the plugin behaviour. |
name | string |
|
The name of the plugin's instance. |
Public Methods
public load(filepath: string): string source
This is called by Rollup when a file is about to be loaded. The method will check if there's a URL setting for it, replace its content with a default export of the file URL and add the file to the queue of files that will be copied after Rollup finishes the bundling process.
Params:
Name | Type | Attribute | Description |
filepath | string | The path to the file to load. |
Return:
string (nullable: true) | If the file path matches a filter, it will return a new export statement,
otherwise, it will return just |
public writeBundle() source
This is called by Rollup after it finishes writing the files on the file system. The method
will loop the queue and copy all the files that matched a filter during the load
process.