vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

unable to locate '.../public/**/*' glob #6281

Closed petergaal91 closed 3 years ago

petergaal91 commented 3 years ago

Version

5.0.0-alpha.3

Environment info

System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 AMD Ryzen 5 2600X Six-Core Processor
  Binaries:
    Node: 14.15.4 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 88.0.4324.150
    Edge: Spartan (44.19041.423.0), Chromium (88.0.705.68)
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.2.1
    @vue/babel-helper-vue-transform-on:  1.0.2
    @vue/babel-plugin-jsx:  1.0.3
    @vue/babel-plugin-transform-vue-jsx:  1.2.1
    @vue/babel-preset-app:  5.0.0-alpha.3
    @vue/babel-preset-jsx:  1.2.4
    @vue/babel-sugar-composition-api-inject-h:  1.2.1
    @vue/babel-sugar-composition-api-render-instance:  1.2.4
    @vue/babel-sugar-functional-vue:  1.2.2
    @vue/babel-sugar-inject-h:  1.2.2
    @vue/babel-sugar-v-model:  1.2.3
    @vue/babel-sugar-v-on:  1.2.3
    @vue/cli-overlay:  5.0.0-alpha.3
    @vue/cli-plugin-babel:  5.0.0-alpha.3
    @vue/cli-plugin-e2e-cypress:  5.0.0-alpha.3
    @vue/cli-plugin-router:  5.0.0-alpha.3
    @vue/cli-plugin-typescript:  5.0.0-alpha.3
    @vue/cli-plugin-vuex:  5.0.0-alpha.3
    @vue/cli-service:  5.0.0-alpha.3
    @vue/cli-shared-utils:  5.0.0-alpha.3
    @vue/compiler-core:  3.0.5
    @vue/compiler-dom:  3.0.5
    @vue/compiler-sfc:  3.0.5
    @vue/compiler-ssr:  3.0.5
    @vue/component-compiler-utils:  3.2.0
    @vue/devtools-api:  6.0.0-beta.6
    @vue/preload-webpack-plugin:  1.1.2
    @vue/reactivity:  3.0.5
    @vue/runtime-core:  3.0.5
    @vue/runtime-dom:  3.0.5
    @vue/shared:  3.0.5
    @vue/web-component-wrapper:  1.3.0
    typescript:  4.1.5 (4.0.5)
    vue:  3.0.5
    vue-class-store:  3.0.0
    vue-hot-reload-api:  2.3.4
    vue-i18n:  9.0.0-rc.6
    vue-loader:  16.1.2 (15.9.6)
    vue-router:  4.0.3
    vue-style-loader:  4.1.2
    vue-template-es2015-compiler:  1.9.1
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

  1. generate an app
  2. delete the public/img folder
  3. serve the app

What is expected?

no error

What is actually happening?

ERROR Failed to compile with 1 error 20:27:47 error

unable to locate 'D:/Workspace/vue3/public/**/*' glob

I think it's a copy-webpack-plugin related bug, but i'm not 100% sure. Related Vue CLI code: here

HexPandaa commented 3 years ago

Hi, I had the same problem while using the 5.0.0-alpha.4 version, I don't have a public/img/ folder, but simply adding a dummy favicon.ico file in the public/ folder fixed the issue. It turns out that I had a a reference to <%= BASE_URL %>favicon.ico in my index.html.

Throwing a more explicit error message might be useful.

@petergaal91 An image might be referenced somewhere in your code, could you provide an example repo or the steps you took to generate the app ?

petergaal91 commented 3 years ago

Yep, the favicons:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="shortcut icon" href="<%= BASE_URL %>assets/images/favicons/android-chrome-192x192.png">
    <link rel="apple-touch-icon" href="<%= BASE_URL %>assets/images/favicons/android-chrome-512x512.png" sizes="512x512">
</head>
<body>
    <div id="app"></div>
</body>
</html>
HexPandaa commented 3 years ago

Yep, the favicons:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <link rel="shortcut icon" href="<%= BASE_URL %>assets/images/favicons/android-chrome-192x192.png">
  <link rel="apple-touch-icon" href="<%= BASE_URL %>assets/images/favicons/android-chrome-512x512.png" sizes="512x512">
</head>
<body>
  <div id="app"></div>
</body>
</html>

Does the app build successfully if you delete the two links to the favicons ?

petergaal91 commented 3 years ago

Unfortunately no, but your solution solved my issue temporary.

The root cause comes from here. the NoErrorOnMissing flag can be a solution in this case

fangbinwei commented 3 years ago

This problem only occurs when the public is an empty folder? Why not remove your public folder directly ? For SPA, this problem occurs If public folder only contains index.html or public folder is empty

petergaal91 commented 3 years ago

public folder contains the index.html so I don't want to delete it. I opened a PR to fix this: PR

fangbinwei commented 3 years ago

Close via #6333