feat: prevent building public files#117
Conversation
|
Is this only an issue in dev mode? What happens on build? |
|
updated
process.env.NODE_ENV === 'development' ? 'foo.js' : 'public/foo.js'maybe we should also ignore public files from here.
|
|
Yeah, I think that'll be the more correct solution. All of the write functions shouldn't be writing anything that exists in the public directory. Similarly for the build functions. |
|
This function will return vite-plugin-web-extension/src/utils/loader.ts Lines 57 to 66 in 600cb8b |
| protected async writeManifestScriptFile(fileName: string): Promise<string> { | ||
| const publicDirName = path.basename(this.publicDir); | ||
| if (fileName.split(path.sep)[0] === publicDirName) { | ||
| await copy(fileName, `${this.outDir}/${fileName}`); |
There was a problem hiding this comment.
Does this copy need to happen? Wouldn't all public files have already been copied by line 67?
There was a problem hiding this comment.
I believe it is necessary because their behaviors are different.
line 67: public/foo.js -> dist/foo.js
this line: public/foo.js -> dist/public/foo.js
There was a problem hiding this comment.
Ah, ok. Line 67 is correct. The contents of public are supposed to be copied to the root of the dist directory not a subdirectory [1] so we wouldn't want this line.
There was a problem hiding this comment.
If we include public/foo.js in the content scripts section of the manifest, it will not be found.
I have a pre-compiled js file under public folder, which is included in the content_scripts of the manifest file. However,
writeBuildwill overwrite it.