Last active
January 16, 2020 23:58
-
-
Save kmrk/bbc52a4d54b407398aff1695e5b710b7 to your computer and use it in GitHub Desktop.
babel --copy-files with --ignore
This file contains hidden or 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
#!/usr/bin/env node | |
// babel's cli option --copy-files will override the --ignore setting | |
// so copy resources like this | |
require('fs-extra').copy( | |
process.argv.slice(-2).shift(), | |
process.argv.slice(-2).pop(), | |
{ filter: (src,dist)=>{ return (src.match(/\.js|\.jsx|stories|test/)===null)} }, | |
err => { if (err) return console.error (err); console.log ('Copy success!'); | |
}); |
This file contains hidden or 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
// package.json | |
... | |
"scripts": { | |
"build-commonjs": "BABEL_ENV=commonjs babel src --out-dir dist/commonjs --ignore '**/test','**/stories' --source-maps inline && ./scripts/--copy-files src dist/commonjs", | |
"build-esm": "BABEL_ENV=esm babel src --out-dir dist/esm --ignore '**/test','**/stories' --source-maps inline && ./scripts/--copy-files src dist/esm", | |
"build": "rimraf dist && 'npm run build-commonjs' 'npm run build-esm'" | |
}, | |
"devDependencies": { | |
"fs-extra": "^8.1.0" | |
}, | |
... |
Author
kmrk
commented
Aug 7, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment