Skip to content

Commit 4bf6768

Browse files
committed
fix build with iife
1 parent 9138e3d commit 4bf6768

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/constants.ts

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

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

src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ 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, styleTemplate } from './constants.js'
15+
import {
16+
grants,
17+
regexpScripts,
18+
regexpStyles,
19+
styleTemplate
20+
} from './constants.js'
1621
import css from './css.js'
1722
import { defineGrants, removeDuplicates, transform } from './helpers.js'
1823
import type { UserscriptPluginConfig } from './types.js'
@@ -81,7 +86,7 @@ export default function UserscriptPlugin(
8186
code = await css.add(src, path)
8287
}
8388

84-
if (path.includes(config.entry)) {
89+
if (path.includes(config.entry) && !src.includes(styleTemplate)) {
8590
code = src + styleTemplate
8691
}
8792

0 commit comments

Comments
 (0)