Skip to content

Commit

Permalink
Fix replacement of templateContent
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusGertdenken committed Nov 15, 2022
1 parent bf6741a commit 32edadd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
legacy-peer-deps = true
legacy-peer-deps = true
registry=https://registry.npmjs.org
11 changes: 10 additions & 1 deletion src/commands/buildCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,20 @@ export function buildCommand({ analyze }: BuildOptions): (stepParams: StepParams
)
return webpackPlugin
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (webpackPlugin.userOptions?.templateContent || webpackPlugin.userOptions?.template) {
if (webpackPlugin.userOptions?.template) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,no-param-reassign
webpackPlugin.userOptions.templateParameters = {
CHAYNS_TOOLKIT_CSS_TAG: `<script>(${loadCss.toString()})()</script>`,
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
} else if (webpackPlugin.userOptions?.templateContent) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,no-param-reassign,@typescript-eslint/no-unsafe-assignment
webpackPlugin.userOptions.templateContent =
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
webpackPlugin.userOptions.templateContent.replace(
"<%= CHAYNS_TOOLKIT_CSS_TAG %>",
`<script>(${loadCss.toString()})()</script>`
)
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return webpackPlugin
Expand Down
11 changes: 10 additions & 1 deletion src/commands/devCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,20 @@ export function devCommand({
)
return webpackPlugin
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (webpackPlugin.userOptions?.templateContent || webpackPlugin.userOptions?.template) {
if (webpackPlugin.userOptions?.template) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,no-param-reassign
webpackPlugin.userOptions.templateParameters = {
CHAYNS_TOOLKIT_CSS_TAG: `<script>(${loadCss.toString()})()</script>`,
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
} else if (webpackPlugin.userOptions?.templateContent) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,no-param-reassign,@typescript-eslint/no-unsafe-assignment
webpackPlugin.userOptions.templateContent =
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
webpackPlugin.userOptions.templateContent.replace(
"<%= CHAYNS_TOOLKIT_CSS_TAG %>",
`<script>(${loadCss.toString()})()</script>`
)
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return webpackPlugin
Expand Down

0 comments on commit 32edadd

Please sign in to comment.