Skip to content

Commit db521bb

Browse files
committed
fix: style template inject
1 parent 2ce4754 commit db521bb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Grants } from './types.js'
22

3+
export const styleTemplate = 'console.warn("__STYLE__")'
34
export const regexpScripts = new RegExp(/\.(t|j)sx?$/)
45
export const regexpStyles = new RegExp(/\.(s[ac]|c|le)ss$/)
56

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { server } from 'websocket'
1212
import type { connection } from 'websocket'
1313
import { Banner } from './banner.js'
1414
import { userConfig } from './config.js'
15-
import { grants, regexpScripts, regexpStyles } from './constants.js'
15+
import { grants, regexpScripts, regexpStyles, styleTemplate } from './constants.js'
1616
import css from './css.js'
1717
import { defineGrants, removeDuplicates, transform } from './helpers.js'
1818
import type { UserscriptPluginConfig } from './types.js'
@@ -82,7 +82,7 @@ export default function UserscriptPlugin(
8282
}
8383

8484
if (path.includes(config.entry)) {
85-
code = src + '__STYLE__'
85+
code = src + styleTemplate
8686
}
8787

8888
return {
@@ -124,7 +124,7 @@ export default function UserscriptPlugin(
124124

125125
try {
126126
let source = readFileSync(outPath, 'utf8')
127-
source = source.replace('__STYLE__', `${css.inject()}`)
127+
source = source.replace(styleTemplate, `${css.inject()}`)
128128
source = await transform({
129129
file: source,
130130
name: fileName,

0 commit comments

Comments
 (0)