1.0.4 • Published 17 days ago

yyl-rev-webpack-plugin v1.0.4

Weekly downloads
13
License
MIT
Repository
github
Last release
17 days ago

yyl-rev-webpack-plugin

USAGE

const YylRevWebpackPlugin = require('yyl-rev-webpack-plugin')
const wConfig = {
  plugins: [
    new YylRevWebpackPlugin({
      context: __dirname,
      /** 文件名称 */
      revFilename: '../assets/rev-manifest.json',
      /** rev 输出内容的相对地址 */
      revRoot: '../',
      /** 线上配置地址,用于映射线上配置在本地生成一模一样的文件 */
      remoteAddr: '',
      /** 映射线上配置时如线上对应本地 css 文件为空时,自动在本地生成空白css */
      remoteBlankCss: true,
      /** 是否映射线上配置 */
      remote: false,
      /** 扩展参数, 会追加到 rev json 里面 */
      extends: {}
    })
  ]
}

hooks

let YylRevWebpackPlugin
try {
  YylRevWebpackPlugin = require('yyl-rev-webpack-plugin')
} catch (e) {
  if (!(e instanceof Error) || e.code !== 'MODULE_NOT_FOUND') {
    throw e
  }
}

const PLUGIN_NAME = 'your_plugin'
class ExtPlugin {
  apply(compiler) {
    const IPlugin = YylRevWebpackPlugin
    if (IPlugin) {
      compiler.hooks.compilation.tap(IPlugin.getName(), (compilation) => {
        IPlugin.getHooks(compilation).afterRev.tapAsync(PLUGIN_NAME, (obj, done) => {
          console.log('hooks.afterRev(obj, done)', 'obj:', obj)
          done(null, obj)
        })

        IPlugin.getHooks(compilation).emit.tapAsync(PLUGIN_NAME, (obj, done) => {
          console.log('hooks.emit(obj, done)', 'obj:', obj)
          done(null, obj)
        })
      })
    }
  }
}

文档

这里

1.0.4

17 days ago

1.0.2

21 days ago

1.0.3

21 days ago

1.0.0

22 days ago

0.1.7

3 months ago

0.1.6

3 months ago

0.1.5

12 months ago

0.1.4

12 months ago

0.1.3

12 months ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago