Created
March 23, 2024 13:00
-
-
Save bitflower/a4539e08ae7ff4320d8182b297834399 to your computer and use it in GitHub Desktop.
Simple Rollup plugin starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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