# Recipes

# Optimize your command

  • Edit /path/to/project/package.json:
{
  // ...
  "scripts": {
    "dev": "gulp",
    "prod": "gulp --production"
  }
  // ...
}
  • For silent mode
{
  // ...
  "scripts": {
    "dev": "gulp --silent",
    "prod": "gulp --silent --production"
  }
  // ...
}

gulp --production alias: gulp -p

gulp --silent alias: gulp -S

Then, you can run the command like this:

  • For development
yarn run dev
# OR
npm run dev
  • For production
yarn run prod
# OR
npm run prod

# Compatibility

# 1. Install the dependency used to provide the necessary runtime helpers

yarn add core-js @babel/runtime-corejs3
# OR
npm i --save core-js @babel/runtime-corejs3

# 2. Upgrade .browserslistrc

ie 8 # add it

# 3. Config babel.config.js

module.exports = function(api) {
  let envOptions = api.env('production')
    ? {
        useBuiltIns: 'entry',
        corejs: { version: 3, proposals: true }
      }
    : {};
  let runtimeOptions = api.env('production') ? { corejs: 3 } : {};

  return {
    presets: [['@babel/preset-env', envOptions]],
    plugins: [['@babel/plugin-transform-runtime', runtimeOptions]]
  };
};

presets options: add modules: 'commonjs' for outdated IE

# 4. Config balm

balm.config = {
  scripts: {
    ie8: true
  }
};

# 5. Upgrade entry js file

  • main.js
import './polyfill';

// Your code
  • polyfill.js
// For IE11 and below
import 'core-js/features/promise';

// For IE8 and below
import 'core-js/features/object/create';
import 'core-js/features/array/for-each';
import 'core-js/features/function/bind';
Last Updated: 7 days ago