Skip to content

Commit 8e23a40

Browse files
committed
Revert web-resources plugin changes
1 parent 883e039 commit 8e23a40

File tree

1 file changed

+7
-16
lines changed
  • programs/develop/webpack/plugin-extension/feature-web-resources

1 file changed

+7
-16
lines changed

programs/develop/webpack/plugin-extension/feature-web-resources/index.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {cleanMatches} from './clean-matches'
1414
* Feature supported:
1515
*
1616
* - web_accessible_resources paths in the manifest.json file.
17-
* - Assets imported from content_scripts files (including CSS files)
17+
* - Assets imported from content_scripts files.
1818
*/
1919
export class WebResourcesPlugin {
2020
public readonly manifestPath: string
@@ -38,18 +38,6 @@ export class WebResourcesPlugin {
3838
const webAccessibleResourcesV2: string[] =
3939
manifest.web_accessible_resources || []
4040

41-
if (manifest.content_scripts && manifest.content_scripts.length > 0) {
42-
if (manifest.manifest_version === 3) {
43-
const contentWildcard = {
44-
resources: ['content_scripts/*'],
45-
matches: ['<all_urls>']
46-
}
47-
webAccessibleResourcesV3.push(contentWildcard)
48-
} else {
49-
webAccessibleResourcesV2.push('content_scripts/*')
50-
}
51-
}
52-
5341
for (const [entryName, resources] of Object.entries(entryImports)) {
5442
const contentScript = manifest.content_scripts?.find((script) =>
5543
script.js?.some((jsFile: string) => jsFile.includes(entryName))
@@ -58,9 +46,12 @@ export class WebResourcesPlugin {
5846
if (contentScript) {
5947
const matches = contentScript.matches || []
6048

61-
// Filter out source maps and JS files, but keep CSS files
49+
// No need to add the output .css and .js to web_accessible_resources
6250
const filteredResources = resources.filter(
63-
(resource) => !resource.endsWith('.map') && !resource.endsWith('.js')
51+
(resource) =>
52+
!resource.endsWith('.map') &&
53+
!resource.endsWith('.css') &&
54+
!resource.endsWith('.js')
6455
)
6556

6657
if (filteredResources.length === 0) {
@@ -82,7 +73,7 @@ export class WebResourcesPlugin {
8273
} else {
8374
webAccessibleResourcesV3.push({
8475
resources: filteredResources,
85-
matches: cleanMatches(matches)
76+
matches: cleanMatches(matches) // Clean matches to conform to the spec
8677
})
8778
}
8879
} else {

0 commit comments

Comments
 (0)