Open honwhy opened 10 months ago
vite build produces multiple js files, that is good. But when js file contains Function, it will be block by firefox CSP policy.
Function
{ content_scripts: [ { "js": [ "src/contents/douban.ts" ], "matches": [ "https://book.douban.com/subject/*" ] }, ] }
compiles to
content_scripts: [ { "js": [ "assets/douban.ts-loader-ddd82093.js" ], "matches": [ "https://book.douban.com/subject/*" ], "css": [ "assets/_plugin-vue_export-helper-175e6fba.css", "assets/el-empty-743b38f5.css", "assets/ContextMenuSearchDrawer-c8e94998.css", "assets/el-link-5aef13b0.css", "assets/douban-3cb6a821.css", "assets/el-loading-6846fe26.css", "assets/el-scrollbar-df5aa9a0.css" ] }, ]
contet of douban.ts-loader-ddd82093.js
douban.ts-loader-ddd82093.js
(function () { 'use strict'; const injectTime = performance.now(); (async () => { const { onExecute } = await import( /* @vite-ignore */ chrome.runtime.getURL("assets/douban.ts-ebbbac0d.js") ); onExecute?.({ perf: { injectTime, loadTime: performance.now() - injectTime } }); })().catch(console.error); })();
abstract of douban.ts-ebbbac0d.js
douban.ts-ebbbac0d.js
import{d as $,o as z,r as x,a as i,c as u,b as c,e as p,u as s,t as f,w as G,i as J,F as C,E as K,f as O,g as P,h as X,j as Y,v as Z,k as ee}from"./element-plus-f1e000a5.js";
key problem, content of element-plus-f1e000a5.js contains Function usage. according to https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy, Function is not supported,
element-plus-f1e000a5.js
any helps is welcome
I guess this is something to do with vite build config,
optimizeDeps: { esbuildOptions: { target: "esnext", }, }, build: { target: "esnext", rollupOptions: { output: { manualChunks: command === 'build' ? { "element-plus": ["element-plus"], echarts: ['echarts'], dayjs: ['dayjs'] } : undefined } } },
should I change setting of build.target ?
so sorry, I have not idea
nice to have
any update about this issue? Thank you
Describe the problem
vite build produces multiple js files, that is good. But when js file contains
Function
, it will be block by firefox CSP policy.manifest.config.ts
compiles to
contet of
douban.ts-loader-ddd82093.js
abstract of
douban.ts-ebbbac0d.js
key problem, content of
element-plus-f1e000a5.js
containsFunction
usage. according to https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy,Function
is not supported,any helps is welcome
Describe the proposed solution
I guess this is something to do with vite build config,
should I change setting of build.target ?
Alternatives considered
so sorry, I have not idea
Importance
nice to have