Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@RoboSparrow
Last active May 15, 2017 09: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 RoboSparrow/13ec07f68d76ca25777eca74c3598ff5 to your computer and use it in GitHub Desktop.
Save RoboSparrow/13ec07f68d76ca25777eca74c3598ff5 to your computer and use it in GitHub Desktop.
Quick and Dirty Rollup copy plugin
//..imports for rollup.config
////
// plugin for copy
////
import fs from 'fs';
import path from 'path';
const copyPlugin = function (options) {
return {
ongenerate(){
const targDir = path.dirname(options.targ);
if (!fs.existsSync(targDir)){
fs.mkdirSync(targDir);
}
fs.writeFileSync(options.targ, fs.readFileSync(options.src));
}
};
};
// end plugin
export default {
//...rollup config
plugins: [
//...other plugins
/*
Example copy non-module: https://github.com/adlnet/xAPIWrapper
*/
copyPlugin({
src: './node_modules/xAPIWrapper/dist/xapiwrapper.min.js',
targ: './dist/xapiwrapper.min.js'
})
],
//...rollup config
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment