Skip to content

Commit

Permalink
Update ResourcesPlugin util method
Browse files Browse the repository at this point in the history
This was the only plugin that didn't use the utils file.
This is for parity.
  • Loading branch information
cezaraugusto committed Feb 29, 2024
1 parent 92f7a55 commit 9d6aed4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
17 changes: 0 additions & 17 deletions packages/resources-plugin/src/helpers/shoudExclude.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {type Compilation} from 'webpack'
import {type Manifest} from '../types'
import {type Manifest} from '../../types'

function getManifestContent(
compilation: Compilation,
Expand All @@ -16,6 +16,13 @@ function getManifestContent(
return require(manifestPath)
}

function shouldExclude(path: string, ignorePatterns: string[]): boolean {
return ignorePatterns.some((pattern) => {
return path.includes(pattern)
})
}

export default {
getManifestContent
getManifestContent,
shouldExclude
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type webpack from 'webpack'
import manifestFields from 'browser-extension-manifest-fields'
import shouldExclude from '../helpers/shoudExclude'
import utils from '../helpers/utils'
import {type WebResourcesPluginInterface} from '../../types'

export default class OutputWebAccessibleResourcesFolder {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default class OutputWebAccessibleResourcesFolder {
)

if (!isContentCss) {
if (!shouldExclude(this.manifestPath, resource, this.exclude)) {
if (!utils.shouldExclude(resource, this.exclude || [])) {
compilation.assets[`web_accessible_resources/${resource}`] =
compilation.assets[resource]
}
Expand All @@ -61,13 +61,7 @@ export default class OutputWebAccessibleResourcesFolder {
)

if (!isContentCss) {
if (
!shouldExclude(
this.manifestPath,
resourcePath,
this.exclude
)
) {
if (!utils.shouldExclude(resourcePath, this.exclude || [])) {
compilation.assets[
`web_accessible_resources/resource-${index}/${resourcePath}`
] = compilation.assets[resourcePath]
Expand Down

0 comments on commit 9d6aed4

Please sign in to comment.