guocaoyi / create-chrome-ext

🍺 Scaffolding your Chrome extension! Boilerplates: react \ vue \ svelte \ solid \ preact \ alpine \ lit \ stencil \ inferno \ vanilla
MIT License
1.42k stars 106 forks source link

The content under public was not copied to the build directory #48

Open lopo12123 opened 9 months ago

lopo12123 commented 9 months ago

The content under public was not copied to the build directory. When I was developing, there was a wasm file that needed to be loaded asynchronously (using fetch in background.js), but when I started dev, it did not seem to be copied to In the build directory, I need to assign values manually. Did I miss something to configure?

lopo12123 commented 9 months ago

image

guocaoyi commented 9 months ago

add publicDir: 'public', in your vite.config.ts

e.g.

export default defineConfig(({ mode }) => {
  return {
    publicDir: 'public',
    build: {
      emptyOutDir: true,
      outDir: 'build',
      ........

use latest version 0.8.7

guocaoyi commented 9 months ago

add publicDir: 'public', in your vite.config.ts

e.g.

export default defineConfig(({ mode }) => {
  return {
    publicDir: 'public',
    build: {
      emptyOutDir: true,
      outDir: 'build',
      ........

use latest version 0.8.7

@lopo12123

lopo12123 commented 9 months ago

@guocaoyi Hi there, i'm sure it's not a problem with the publicDir setting, because it defaults to 'public' (I don't need to set it at all). Maybe you can try to reproduce it using the following situation...


Neither example.txt file is copied to the build folder (unless I specify it in web_accessible_resources.resources in manifest.ts)

image

In the picture below, I specified example.txt under public, and you can see that it was copied to build, but icons/example.txt was not (because I did not specify it in web_accessible_resources.resources) image image

Then I specified two example.txt, and you can see that they are now copied. image image

guocaoyi commented 9 months ago

Ok, thanks for the clarification.

lopo12123 @.***> 于2023年10月8日周日 10:02写道:

I'm sure it's not a problem with the publicDir setting, because it defaults to 'public'. So I don't need to set it at all.

Neither example.txt file is copied to the build folder (unless I specify it in web_accessible_resources.resources in manifest.ts)

[image: image] https://user-images.githubusercontent.com/59609929/273420741-f85499e2-d05a-4e75-90c0-fe086a308e1e.png

In the picture below, I specified example.txt under public, and you can see that it was copied to build, but icons/example.txt was not (because I did not specify it in web_accessible_resources.resources) [image: image] https://user-images.githubusercontent.com/59609929/273420771-4081488f-47c4-47ed-853f-8726aed90fae.png [image: image] https://user-images.githubusercontent.com/59609929/273420877-ea361139-dbb9-4d7d-951d-3503ef04eedd.png

Then I specified two example.txt, and you can see that they are now copied. [image: image] https://user-images.githubusercontent.com/59609929/273420910-ee60a5ff-a7bb-466f-9c83-51881879b65f.png [image: image] https://user-images.githubusercontent.com/59609929/273420898-f0dfe809-0cd0-4c72-a197-a1b9b9e09818.png

— Reply to this email directly, view it on GitHub https://github.com/guocaoyi/create-chrome-ext/issues/48#issuecomment-1751892321, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ7C2FPJOIQYF74UXVRN6QTX6ICUTAVCNFSM6AAAAAA5VYQXXOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJRHA4TEMZSGE . You are receiving this because you modified the open/close state.Message ID: @.***>