Last active
May 15, 2017 09:00
-
-
Save RoboSparrow/13ec07f68d76ca25777eca74c3598ff5 to your computer and use it in GitHub Desktop.
Quick and Dirty Rollup copy plugin
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
//..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