Skip to content

Instantly share code, notes, and snippets.

@bitflower
Created March 23, 2024 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitflower/a4539e08ae7ff4320d8182b297834399 to your computer and use it in GitHub Desktop.
Save bitflower/a4539e08ae7ff4320d8182b297834399 to your computer and use it in GitHub Desktop.
Simple Rollup plugin starter
// import { createFilter } from 'rollup-pluginutils'
function assign(target, source) {
Object.keys(source).forEach((key) => {
target[key] = source[key];
});
return target;
}
// const DEFAULT_HEADER = 'import React from \'react\';'
module.exports = (opts) => {
opts = assign({}, opts || {});
// if (!opts.include) {
// throw Error('include option should be specified');
// }
// let filter = createFilter(opts.include, opts.exclude)
// let header = opts.header !== undefined ? opts.header : DEFAULT_HEADER
return {
name: 'add-import',
transform(code, id) {
console.log('MY PLUGIN', code);
// if (!filter(id)) return
// return {
// code: header + '\n' + code,
// map: { mappings: '' }
// }
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment