vite-plugin-web-extension
vite-plugin-web-extension copied to clipboard
feat: prevent building public files
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.
Is this only an issue in dev mode? What happens on build?
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.~~
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 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