Skip to content

Latest commit

 

History

History
74 lines (62 loc) · 1.78 KB

README-zh_CN.md

File metadata and controls

74 lines (62 loc) · 1.78 KB

perfume-webpack-plugin

Build Status Coverage Status GitHub GitHub package.json version

perfume.js的Webpack插件

English | 简体中文

安装:

首先安装npm包

npm i perfume-webpack-plugin -D

导入库

import PerfumeWebpackPlugin from 'perfume-webpack-plugin'

如果使用CommonJS的方式导入

const PerfumeWebpackPlugin = require('perfume-webpack-plugin').default

示例:

const apiKey = 'xxx'
module.exports = {
  plugins: [
    new PerfumeWebpackPlugin({
      entry: /app\.js$/,
      fps: true,
      dataConsumption: true,
      resourceTiming: true,
      cumulativeLayoutShift: true,
      isMerge: true,
      reportUrl: `https://example.com/report?apiKey=${apiKey}`,
      ignoreResource: [{ key: 'name', value: '/report' }],
      logging: false,
    })
  ]
}

默认选项:

const options = {
  entry: /app\.js$/,
  // Metrics
  fps: false,
  dataConsumption: false,
  resourceTiming: false,
  cumulativeLayoutShift: false,
  // Analytics
  tag: '',
  reportUrl: '',
  ignoreResource: [],
  isMerge: false,
  analyticsTracker: option => {},
  // Logging
  logPrefix: 'Perfume.js:',
  logging: true,
  maxMeasureTime: 15000,
};

License