I'm fairly new to both NPM scripts and Babel. I've used Gulp before but I'm trying to move towards Webpack + NPM scripts or even NPM only builds when Webpack isn't needed. This is one such example of the latter.
I would like to
- use my main ES6+ JS file
src/main.js use babel to produce a fairly modern script file
docs/main.jsusing a target like:browsers: [ 'Chrome >= 60', 'Safari >= 10.1', 'iOS >= 10.3', 'Firefox >= 54', 'Edge >= 15', ],use babel again to produce a more 'legacy' version of the scripts
docs/main.legacy.jsusing a target like:"browsers": ["> 1%, not ie 11, not op_mini all"]- use npm scripts to create two build tasks out of this which I can later put into one command such as
npm run build
After reading Philip Walton's article on creating multiple targets in his build process, I would like to know:
- Is this possible with NPM scripts only if I don't need Webpack?
- What is the recommended course of action to enable such functionality?
My attempts: package.json
"scripts": {
"buildModern": "babel src/main.js -o docs/main.js -presets=env",
"buildLegacy": "babel --no-babelrc src/main.js > docs/main.legacy.js",
"build": "echo '=> Building Source Files' && buildModern && buildLegacy"
},