Closed Rhilip closed 2 years ago
I specifically set them to {}
because the rollup options can't be shared between the multi-page build and the library builds.
I can add another plugin option like libModeViteConfig
that would support overriding the rollup options for those builds
Alright, I've implmented libModeViteConfig
and released it in v1.3.0
. For an example of configuring the lib mode builds for your case, see the tests:
@Rhilip if that doesn't work for you, feel free to reopen with more details.
Vite provide a Glob Import feature , however when use this feature function
import.meta.glob
in script, the build will fail and with this output:It's ok when use function
import.meta.globEager
since this function will not splitting code.Steps to reproduce
src/background/module/1.ts
andsrc/background/module/2.ts
, each may have simple code likeconsole.log("hello world");
src/background/index.ts
, add lineconsole.log(import.meta.glob("./module/*.ts"));
pnpm run build
and see error code, nodist/background
folder will be built.Try to fix
["umd"]
to["es"]
, it worked as except, and1.js
,2.js
,index.js
in output dirdist/background
build.rollupOptions.output.inlineDynamicImports: true
to avoid this problem, however it still not work if we change projectvite.config.ts
file, since build-script always use a empty rollupOptions. https://github.com/aklinker1/vite-plugin-web-extension/blob/5faeb5af478d1468e0abf5a516d32edfc69c2a8c/lib/src/build-script.ts#L45