English | 中文
A Webpack Plugin to reduce ts enum to js artifacts
eg:
before add plugin:
enum Status {
PAID,
UN_PAID
}
// =>
var Status;
(function (Status) {
Status[Status.PAID = 0] = 'PAID'
Status[Status.UN_PAID = 1] = 'UN_PAID'
})(Status || (Status = {}))
after add plugin:
enum Status {
PAID,
UN_PAID
}
// =>
var Status = {
PAID: 0,
UN_PAID: 1
}
pnpm add reduce-enum-webpack-plugin -D
# or
yarn add reduce-enum-webpack-plugin -D
# or
npm i reduce-enum-webpack-plugin -D
const ReduceEnumWebpackPlugin = require('reduce-enum-webpack-plugin').default
// webpack.config.js
module.exports = {
plugins: [
isProduction && new ReduceEnumWebpackPlugin()
],
}
reduce-enum-webpack-plugin is MIT licensed.