Closed nerblock closed 2 years ago
I went through the source and realized that the problem is in fact in rollup-plugin-chrome-extension
. It has different code paths for MV2 and MV3, and MV3 support looks unfinished.
Here is a quick fix:
In node_modules/rollup-plugin-chrome-extension/src/manifest-input/updateManifest.ts
in the updateManifestV3
function find this part:
const resources = [
`${chunkFileNames
.split('/')
.join('/')
.replace('[format]', '*')
.replace('[name]', '*')
.replace('[hash]', '*')}`,
...cache.contentScripts.map((x) =>
path.relative(cache.srcDir, x),
),
];
and replace with this:
const resources = [
slash(`${chunkFileNames
.split('/')
.join('/')
.replace('[format]', '*')
.replace('[name]', '*')
.replace('[hash]', '*')}`),
...cache.contentScripts.map((x) =>
slash(path.relative(cache.srcDir, x)),
),
];
Basically one needs to wrap the paths in the slash() function to make them work on Windows.
moved the issue to the correct repo, closing this
Describe the bug
When building the project for MV3 on a Windows machine the content script can't be loaded, because the path separators in the
web_accessible_resources
section in the generateddist/manifest.json
file are incorrecty converted to Windows style path separators:How do we reproduce?
src/manifest.json
for MV3:npm run build
Expected behavior
manifest.json should contain Unix style path separators:
Actual behavior
Running
npm run build
on a Linux machine (or in WSL) generatesdist/manifest.json
with/
(slash) as path separator.Running
npm run build
on a Windows machine generatesdist/manifest.json
with\
(backslash) as path separator.