1.1.2 • Published 3 years ago

@panhezeng/before-run-webpack-plugin v1.1.2

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
3 years ago

before-run-webpack-plugin

说明

一个简单插件,在 webpack compiler 运行前,注入执行一个方法。 我写来是为了输出示例的,默认有个方法

let cb = () => {
  let outputPath = "docs";
  let srcPath = "index.html";
  shell.rm("-rf", outputPath);
  shell.mkdir(outputPath);
  shell.cp("-R", srcPath, outputPath);
  if (optionsIsObj && this.options.sed) {
    switch (this.options.sed) {
      case "react":
        shell.sed(
          "-i",
          /(react-dom|react)\.development\.js/,
          "$1.production.min.js",
          outputPath + "/" + srcPath
        );
        break;
      case "vue":
        shell.sed("-i", "vue.js", "vue.min.js", outputPath + "/" + srcPath);
        break;
    }
  }
};

参数 {cb, sed }

用法

npm i @panhezeng/before-run-webpack-plugin -D

const BeforeRunWebpackPlugin = require("@panhezeng/before-run-webpack-plugin");

module.exports = {
  plugins: [
    new BeforeRunWebpackPlugin({
      cb: function() {
        console.log("before run");
      }
    })
  ]
};

编译

# install dependencies
npm install

# 编译插件
npm run build

# 发版
npm set registry https://registry.npmjs.org/ && npm set @panhezeng:registry https://registry.npmjs.org/ && npm publish --access public && npm set registry https://registry.npm.taobao.org/ && npm set @panhezeng:registry https://registry.npm.taobao.org/

# 发版patch
npm set registry https://registry.npmjs.org/ && npm set @panhezeng:registry https://registry.npmjs.org/ && npm version patch && npm publish --access public && npm set registry https://registry.npm.taobao.org/ && npm set @panhezeng:registry https://registry.npm.taobao.org/
1.1.2

3 years ago

1.1.1

4 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago