上QQ阅读APP看书,第一时间看更新
Ensuring cross-platform compatibility
Before we move on, we should try to ensure our npm scripts work across multiple platforms. So, if we have a developer working on a Mac, and another on a Linux machine, the script would work for both of them.
For example, if you want to remove the dist directory using cmd in Windows, you'd have to run rd /s /q dist; while using Ubuntu's default shell (Bash), you'll run rm -rf dist. To ensure our npm script will work everywhere, we can use a Node package called rimraf (https://www.npmjs.com/package/rimraf). First, install it:
$ yarn add rimraf --dev
And now update our build script to use rimraf:
"build": "rimraf dist && babel src -d dist",