- 安装
npm i -D babel-plugin-math-precision
-
使用方法
- babel.rc
{ "plugins": ["math-precision"] }
- webpack.config.js
{ test: /\.js|x$/, loader: 'babel-loader', option: { plugins: [ require('babel-plugin-math-precision') ] } }
-
实例
// 代码中 const a = 1 + 2; // 打包后 var { mathPlus } = require("babel-plugin-math-precision/lib/mathCalc.js"); const a = mathPlus(1, 2);