-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
407 additions
and
327 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Plugin } from 'vite' | ||
import { dirname, relative } from 'node:path' | ||
|
||
const assetsRewritePlugin: Plugin = { | ||
name: 'assets-rewrite', | ||
enforce: 'post', | ||
apply: 'build', | ||
transformIndexHtml(html, { path }) { | ||
const assetsPath = relative(dirname(path), '/assets').replace(/\\/g, '/') | ||
return html.replace(/"\/assets\//g, `"${assetsPath}/`) | ||
}, | ||
} | ||
|
||
export default assetsRewritePlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Plugin } from 'vite' | ||
|
||
const viteManifestHackIssue846: Plugin & { | ||
renderCrxManifest: (manifest: any, bundle: any) => void | ||
} = { | ||
// Workaround from https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919. | ||
name: 'manifestHackIssue846', | ||
renderCrxManifest(_manifest, bundle) { | ||
bundle['manifest.json'] = bundle['.vite/manifest.json'] | ||
bundle['manifest.json'].fileName = 'manifest.json' | ||
delete bundle['.vite/manifest.json'] | ||
}, | ||
} | ||
|
||
export default viteManifestHackIssue846 |
25 changes: 25 additions & 0 deletions
25
packages/extension-vite/configs/vite/transform-manifest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Plugin, ResolvedConfig } from 'vite' | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
|
||
function myPlugin(): Plugin { | ||
let config: ResolvedConfig | ||
|
||
return { | ||
name: 'my-plugin:build', | ||
apply: 'build', | ||
async configResolved(_config) { | ||
config = _config | ||
}, | ||
writeBundle() { | ||
const filePath = path.resolve( | ||
config.root, | ||
config.build.outDir, | ||
'sprite.svg', | ||
) | ||
fs.ensureFileSync(filePath) | ||
fs.writeFileSync(filePath, 'abc') | ||
}, | ||
} | ||
} | ||
export default myPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
bafb995
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Virus total analysis
chrome:
https://www.virustotal.com/gui/file/445f074be00a181d7f18ad385037a3208503ab4e201fb06c9093e665ff0b1962
firefox:
https://www.virustotal.com/gui/file/6101ef5dd126de9428d619ec0b140790745a02192bf7f35a44d225f88798cd12