Skip to content

Commit 9eb243f

Browse files
committed
feat: minify in development mode
1 parent 1ae6e87 commit 9eb243f

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ export function removeDuplicates(arr: any): any[] {
77
}
88

99
export async function transform({
10+
minify,
1011
file,
1112
name,
1213
loader
1314
}: Transform): Promise<string> {
1415
const { code } = await transformWithEsbuild(file, name, {
16+
minify,
1517
loader,
16-
minify: true,
1718
sourcemap: false,
1819
legalComments: 'none'
1920
})

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export default function UserscriptPlugin(
146146
let source = readFileSync(outPath, 'utf8')
147147
source = source.replace(styleTemplate, `${css.inject()}`)
148148
source = await transform({
149+
minify: !isBuildWatch,
149150
file: source,
150151
name: fileName,
151152
loader: 'js'
@@ -161,6 +162,7 @@ export default function UserscriptPlugin(
161162
const wsFile = readFileSync(resolve(pluginDir, 'ws.js'), 'utf8')
162163

163164
const wsScript = await transform({
165+
minify: !isBuildWatch,
164166
file: wsFile.replace('__WS__', `ws://localhost:${port}`),
165167
name: wsPath,
166168
loader: 'js'

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GM, GMwindow } from './constants.js'
22

33
export interface Transform {
4+
minify: boolean
45
file: string
56
name: string
67
loader: 'js' | 'css'

0 commit comments

Comments
 (0)