UNPKG

@roots/bud-minify

Version:

CSS and JS minification for bud.js

147 lines (146 loc) 4.22 kB
import { __decorate } from "tslib"; import { Extension, } from '@roots/bud-framework/extension'; import { bind, deprecated, options, } from '@roots/bud-framework/extension/decorators'; /** * Terser configuration */ let BudMinimizeJSPublicApi = class BudMinimizeJSPublicApi extends Extension { /** * @deprecated Use {@link BudTerser.dropComments} instead */ comments(comments = true) { this.set(`terserOptions.format.comments`, comments); return this; } /** * @deprecated Use {@link BudTerser.dropDebugger} instead */ debugger(enable = true) { this.set(`terserOptions.compress.drop_debugger`, enable); return this; } /** * Drop comments */ dropComments(enable = true) { this.set(`terserOptions.format.comments`, !enable); return this; } /** * Drop console */ dropConsole(enable = true) { this.set(`terserOptions.compress.drop_console`, enable); return this; } /** * Drop debugger statements */ dropDebugger(enable = true) { this.set(`terserOptions.compress.drop_debugger`, enable); return this; } /** * Mangle output * @deprecated Use {@link BudTerser.set} instead * * @example * ```js * bud.minimize.js.set(`terserOptions.mangle`, {}) * ``` */ mangle(mangle) { this.set(`terserOptions.mangle`, mangle); return this; } /** * @deprecated Use {@link BudTerser.set} instead * * @example * ```js * bud.minimize.js.set(`terserOptions.minify`, () => {}) * ``` */ setMinifier(minify) { this.set(`minify`, minify); return this; } }; __decorate([ deprecated(`bud.minimize.js`, `Use bud.minimize.js.dropComments instead`, [ [`Drop comments`, `bud.minimize.js.dropComments()`], [`Preserve comments`, `bud.minimize.js.dropComments(false)`], [ `Alternative (using bud.minimize.js.set)`, `bud.minimize.js.set('terserOptions.format.comments', true)`, ], ]) ], BudMinimizeJSPublicApi.prototype, "comments", null); __decorate([ deprecated(`bud.minimize.js`, `Use bud.minimize.js.dropDebugger instead`, [ [`Drop debugger statements`, `bud.minimize.js.dropDebugger()`], [ `Preserve debugger statements`, `bud.minimize.js.dropDebugger(false)`, ], [ `Alternative (using bud.minimize.js.set)`, `bud.minimize.js.set('terserOptions.compress.drop_debugger', true)`, ], ]) ], BudMinimizeJSPublicApi.prototype, "debugger", null); __decorate([ bind ], BudMinimizeJSPublicApi.prototype, "dropComments", null); __decorate([ bind ], BudMinimizeJSPublicApi.prototype, "dropConsole", null); __decorate([ bind ], BudMinimizeJSPublicApi.prototype, "dropDebugger", null); __decorate([ bind // @ts-ignore ], BudMinimizeJSPublicApi.prototype, "mangle", null); __decorate([ deprecated(`bud.minimize.js`, `Use bud.minimize.js.setMinify instead`, [ [ `Set the minifier`, `bud.minimize.js.set('terserOptions.minify', () => minifier)`, ], ]) ], BudMinimizeJSPublicApi.prototype, "setMinifier", null); BudMinimizeJSPublicApi = __decorate([ options({ exclude: undefined, extractComments: false, include: undefined, minify: undefined, parallel: true, terserOptions: { compress: { defaults: true, drop_console: false, drop_debugger: true, unused: true, }, ecma: `2020`, enclose: false, format: { ascii_only: true, comments: false, }, ie8: false, keep_classnames: false, keep_fnames: false, mangle: {}, module: false, nameCache: {}, parse: {}, safari10: false, sourceMap: false, toplevel: true, }, }) ], BudMinimizeJSPublicApi); export { BudMinimizeJSPublicApi, };