Here's my Makefile, which includes all the configuration: react, babel, etc. (I do not have any dotfiles in root except for linter). `watch` recompiles on changes and has sourcemaps. You can require any node modules and calls to `fs.readFileSync` will be replaced with `Buffer` objects.
NODE_MODULES=../../node_modules
NODE_BINARIES=${NODE_MODULES}/.bin
BABEL_PRESETS=--presets [ es2017 react ]
BABEL_PLUGINS=--plugins [ transform-object-rest-spread ]
FLAGS= \
--transform [ babelify ${BABEL_PLUGINS} ${BABEL_PRESETS} ] \
--transform brfs \
--outfile ../../public/bundle.js \
entrypoint.js
build:
${NODE_BINARIES}/browserify ${FLAGS}
watch:
${NODE_BINARIES}/watchify --debug --verbose ${FLAGS}
What it doesn't have is any kind of automatic page reload or code swap and you can't `require` non-js files. There is also no minification for production build. I believe you can have those after couple of minutes on npm, but I haven't tried. Dependencies:
yarn add --dev browserify watchify babelify babel-plugin-transform-object-rest-spread babel-preset-es2017 babel-preset-react brfs