Skip to content

Commit cdd2024

Browse files
committed
fix: minify css
1 parent e4590d3 commit cdd2024

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/css.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
import { transform } from './helpers.js'
2-
31
export class CSS {
42
private readonly styles = new Map<string, string>()
53

6-
async add(code: string, path: string): Promise<string> {
7-
const style = await transform({
8-
file: code,
9-
name: path,
10-
loader: 'css'
11-
})
12-
13-
this.styles.set(path, style.replace('\n', ''))
4+
add(path: string, styles: string): string {
5+
this.styles.set(path, styles.replace('\n', ''))
146
return ''
157
}
168

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ export default function UserscriptPlugin(
9797
let code = src
9898

9999
if (regexpStyles.test(path)) {
100-
code = await css.add(src, path)
100+
const styles = await transform({
101+
minify: !isBuildWatch,
102+
file: code,
103+
name: path,
104+
loader: 'css'
105+
})
106+
code = css.add(path, styles)
101107
}
102108

103109
if (path.includes(config.entry)) {

0 commit comments

Comments
 (0)