vite-plugin-web-extension icon indicating copy to clipboard operation
vite-plugin-web-extension copied to clipboard

feat: prevent building public files

Open maltoze opened this issue 2 years ago • 4 comments

I have a pre-compiled js file under public folder, which is included in the content_scripts of the manifest file. However, writeBuild will overwrite it.

maltoze avatar Jun 08 '23 08:06 maltoze

Is this only an issue in dev mode? What happens on build?

samrum avatar Jun 09 '23 03:06 samrum

updated

~~using this in my manifest.😂~~

process.env.NODE_ENV === 'development' ? 'foo.js' : 'public/foo.js'

maybe we should also ignore public files from here. https://github.com/samrum/vite-plugin-web-extension/blob/600cb8b294e8cdfc44bccb7d3c50275a8c447486/src/devBuilder/devBuilder.ts#L179

~~then there is no need to check NODE_ENV and use public/foo.js directly.~~

maltoze avatar Jun 09 '23 05:06 maltoze

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.

samrum avatar Jul 04 '23 00:07 samrum

This function will return null when building. It seems that we only need to focus on dev mode. https://github.com/samrum/vite-plugin-web-extension/blob/600cb8b294e8cdfc44bccb7d3c50275a8c447486/src/utils/loader.ts#L57-L66

maltoze avatar Jul 04 '23 03:07 maltoze