Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite only importing some of the files in a folder #10425

Closed
7 tasks done
JerryBels opened this issue Oct 11, 2022 · 2 comments
Closed
7 tasks done

Vite only importing some of the files in a folder #10425

JerryBels opened this issue Oct 11, 2022 · 2 comments

Comments

@JerryBels
Copy link

JerryBels commented Oct 11, 2022

Describe the bug

Hey guys, I wanted to copy over my images assets to the built assets. I added import.meta.glob('../images/**'); to my app.js file, and ran the build command. But it looks like there was an issue with one of the images, and it failed to be imported. The thing is, if I select that image specifically and remove the wildcard, it is correctly imported. But if I let the wildcard up, only a few images are imported (I guess until it reaches the problematic image in the process).

I created a project with the issue (it's a Laravel project but whatever, it demonstrates the issue well). The problematic image is production_icon.jpg.

Reproduction

https://github.com/JerryBels/vite-image-bug

Steps to reproduce

npm install
npm run build

see that the production_icon.png image hasn't been imported.

System Info

WSL on Windows 11 

  System:
    OS: Linux 5.10 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 7.28 GB / 15.49 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 99.0.4844.51
  npmPackages:
    vite: ^3.0.0 => 3.1.7

Used Package Manager

npm

Logs

Click to expand!
$ vite build --debug
  vite:config bundled config file loaded in 39.27ms +0ms
  vite:esbuild init tsconfck (root: /home/jb/projects/example-app) +0ms
  vite:esbuild init tsconfck (root: /home/jb/projects/example-app) +1ms
  vite:esbuild init tsconfck (root: /home/jb/projects/example-app) +0ms
  vite:esbuild init tsconfck (root: /home/jb/projects/example-app) +0ms
  vite:esbuild init tsconfck end +150ms
  vite:esbuild init tsconfck end +0ms
  vite:esbuild init tsconfck end +0ms
  vite:esbuild init tsconfck end +0ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'vite:build-metadata',
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm-helper',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:wasm-fallback',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:force-systemjs-wrap-complete',
  vite:config     'vite:watch-package-data',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'vite:asset-import-meta-url',
  vite:config     'vite:dynamic-import-vars',
  vite:config     'vite:import-glob',
  vite:config     'laravel',
  vite:config     'vite:build-import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:manifest',
  vite:config     'vite:reporter',
  vite:config     'vite:load-fallback'
  vite:config   ],
  vite:config   optimizeDeps: {
  vite:config     disabled: 'build',
  vite:config     force: undefined,
  vite:config     esbuildOptions: { preserveSymlinks: undefined }
  vite:config   },
  vite:config   build: {
  vite:config     target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'public/build',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 0,
  vite:config     cssCodeSplit: true,
  vite:config     cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari13' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: { input: [Array] },
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: true,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
  vite:config   },
  vite:config   base: '/build/',
  vite:config   publicDir: '',
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     origin: '__laravel_vite_placeholder__',
  vite:config     middlewareMode: false,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] }
  vite:config   },
  vite:config   resolve: { alias: [ [Object], [Object], [Object] ] },
  vite:config   ssr: {
  vite:config     format: 'esm',
  vite:config     target: 'node',
  vite:config     noExternal: [ 'laravel-vite-plugin' ],
  vite:config     optimizeDeps: { disabled: true, esbuildOptions: [Object] }
  vite:config   },
  vite:config   configFile: '/home/jb/projects/example-app/vite.config.js',
  vite:config   configFileDependencies: [ '/home/jb/projects/example-app/vite.config.js' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     optimizeDeps: { force: undefined },
  vite:config     build: {}
  vite:config   },
  vite:config   root: '/home/jb/projects/example-app',
  vite:config   cacheDir: '/home/jb/projects/example-app/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isWorker: false,
  vite:config   mainConfig: null,
  vite:config   isProduction: true,
  vite:config   preview: {
  vite:config     port: undefined,
  vite:config     strictPort: undefined,
  vite:config     host: undefined,
  vite:config     https: undefined,
  vite:config     open: undefined,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   env: {
  vite:config     VITE_PUSHER_APP_KEY: '',
  vite:config     VITE_PUSHER_HOST: '',
  vite:config     VITE_PUSHER_PORT: '443',
  vite:config     VITE_PUSHER_SCHEME: 'https',
  vite:config     VITE_PUSHER_APP_CLUSTER: 'mt1',
  vite:config     BASE_URL: '/build/',
  vite:config     MODE: 'production',
  vite:config     DEV: false,
  vite:config     PROD: true
  vite:config   },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(0) { set: [Function (anonymous)] },
  vite:config   createResolver: [Function: createResolver],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       'vite:build-metadata',
  vite:config       'vite:pre-alias',
  vite:config       'alias',
  vite:config       'vite:modulepreload-polyfill',
  vite:config       'vite:resolve',
  vite:config       'vite:html-inline-proxy',
  vite:config       'vite:css',
  vite:config       'vite:esbuild',
  vite:config       'vite:json',
  vite:config       'vite:wasm-helper',
  vite:config       'vite:worker',
  vite:config       'vite:asset',
  vite:config       'vite:wasm-fallback',
  vite:config       'vite:define',
  vite:config       'vite:css-post',
  vite:config       'vite:build-html',
  vite:config       'vite:worker-import-meta-url',
  vite:config       'vite:force-systemjs-wrap-complete',
  vite:config       'vite:watch-package-data',
  vite:config       'commonjs',
  vite:config       'vite:data-uri',
  vite:config       'vite:asset-import-meta-url',
  vite:config       'vite:dynamic-import-vars',
  vite:config       'vite:import-glob',
  vite:config       'vite:build-import-analysis',
  vite:config       'vite:esbuild-transpile',
  vite:config       'vite:terser',
  vite:config       'vite:manifest',
  vite:config       'vite:reporter',
  vite:config       'vite:load-fallback'
  vite:config     ],
  vite:config     rollupOptions: {},
  vite:config     getSortedPlugins: [Function: getSortedPlugins],
  vite:config     getSortedPluginHooks: [Function: getSortedPluginHooks]
  vite:config   },
  vite:config   appType: 'spa',
  vite:config   experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false },
  vite:config   getSortedPlugins: [Function: getSortedPlugins],
  vite:config   getSortedPluginHooks: [Function: getSortedPluginHooks]
  vite:config } +158ms
vite v3.1.7 building for production...
✓ 63 modules transformed.
public/build/assets/local_icon.10583dee.png   8.10 KiB
public/build/assets/favicon.89023b7e.ico      215.45 KiB
public/build/assets/logo.855756de.png         80.02 KiB
public/build/manifest.json                    0.62 KiB
public/build/assets/app.7c3c19f8.js           0.00 KiB / gzip: 0.02 KiB
public/build/assets/app.7c828056.js           90.63 KiB / gzip: 33.07 KiB

Validations

@sapphi-red
Copy link
Member

Closing as this is fixed by #9928 that is release with 3.2.0-beta.1.

After upgrading, you can see manifest.json including both production_icon.png and logo.png. (Since they are the same image, they point to the same file.)

{
  "resources/images/favicon.ico": {
    "file": "assets/favicon.89023b7e.ico",
    "src": "resources/images/favicon.ico"
  },
  "resources/images/local_icon.png": {
    "file": "assets/local_icon.10583dee.png",
    "src": "resources/images/local_icon.png"
  },
  "resources/images/logo.png": {
    "file": "assets/logo.855756de.png",
    "src": "resources/images/logo.png"
  },
  "resources/css/app.css": {
    "file": "assets/app.7c3c19f8.js",
    "src": "resources/css/app.css",
    "isEntry": true
  },
  "resources/js/app.js": {
    "file": "assets/app.b4d72609.js",
    "src": "resources/js/app.js",
    "isEntry": true
  },
  "resources/images/production_icon.png": {
    "file": "assets/logo.855756de.png",
    "src": "resources/images/production_icon.png"
  }
}

@JerryBels
Copy link
Author

Oh great, I searched for this but not for the right issue then. Thanks :)

@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants