I managed to create the library without extracting and using the internal dependencies of creating the application-application. I tested it with react-scripts@0.9.5 . First you need to install babel-cli :
npm install
create a .babelrc file with content:
{ "presets": ["react-app"] }
Then add the script to package.json :
"compile": "NODE_ENV=production babel src --out-dir lib --copy-files",
And finally do:
npm run compile
This will compile all sources from the src directory to lib and simply copy the remaining files. Remember to declare the main file in package.json (for example, "main"="lib/index.js" ).
However, there is one caveat. If you use files that cannot be compiled using babel (for example, css or fonts), users of your library will need to configure the appropriate loaders (webpack).
madox2
source share