vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.64k stars 6.2k forks source link

[vite:css] ENOENT: no such file or directory, stat '/resource/loading.css' #6886

Closed honghuangdc closed 2 years ago

honghuangdc commented 2 years ago

Describe the bug

This problem occurs when this version of vite is 2.8.0 or 2.8.1, it is normal in version 2.7.13. the file '/resource/loading.css' is inside directory public. this relative code is in index.html:

<style>
      @import '/resource/loading.css';
</style>

Reproduction

https://github.com/honghuangdc/soybean-admin/blob/main/index.html

System Info

System:
    OS: macOS 12.2
    CPU: (12) x64 Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
    Memory: 2.14 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.1 - /usr/local/opt/node@14/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 6.14.15 - /usr/local/opt/node@14/bin/npm
    Watchman: 2021.12.20.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 98.0.4758.80
    Safari: 15.3
  npmPackages:
    @vitejs/plugin-vue: ^2.2.0 => 2.2.0 
    vite: 2.8.1 => 2.8.1

Used Package Manager

pnpm

Logs

❯ pnpm vite build --debug
  vite:config bundled config file loaded in 317.77ms +0ms
[dotenv][DEBUG] did not match key and value when parsing line 2: 
[dotenv][DEBUG] did not match key and value when parsing line 4: 
[dotenv][DEBUG] did not match key and value when parsing line 6: 
[dotenv][DEBUG] did not match key and value when parsing line 8: 
  vite:config using resolved config: {
  vite:config   base: '/',
  vite:config   resolve: {
  vite:config     dedupe: undefined,
  vite:config     alias: [ [Object], [Object], [Object], [Object] ]
  vite:config   },
  vite:config   define: {
  vite:config     PROJECT_BUILD_TIME: '"2022-02-12 23:55:46"',
  vite:config     __VUE_OPTIONS_API__: true,
  vite:config     __VUE_PROD_DEVTOOLS__: false
  vite:config   },
  vite:config   plugins: [
  vite:config     'alias',
  vite:config     'vite:inject-html',
  vite:config     'unplugin-icons',
  vite:config     'vite-plugin-windicss:alias',
  vite:config     'vite-plugin-windicss:groups',
  vite:config     'vite:mock',
  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',
  vite:config     'vite:worker',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:asset',
  vite:config     'vite:vue',
  vite:config     'vite-plugin-windicss',
  vite:config     'vite-plugin-windicss:css',
  vite:config     'vite-plugin-windicss:css:svelte',
  vite:config     'vite-plugin-windicss:devtools',
  vite:config     'visualizer',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:watch-package-data',
  vite:config     'vite:build-html',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'rollup-plugin-dynamic-import-variables',
  vite:config     'vite:asset-import-meta-url',
  vite:config     'vite:minify-html',
  vite:config     'unplugin-vue-components',
  vite:config     'vite-plugin-windicss:entry',
  vite:config     'vite:build-import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:reporter',
  vite:config     'vite:load-fallback'
  vite:config   ],
  vite:config   css: { preprocessorOptions: { scss: [Object] } },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     fs: { strict: false, allow: [Array], deny: [Array] },
  vite:config     host: '0.0.0.0',
  vite:config     port: 3200,
  vite:config     open: true
  vite:config   },
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     cssTarget: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  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     brotliSize: false,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] }
  vite:config   },
  vite:config   ssr: { external: [ 'vue', '@vue/server-renderer' ] },
  vite:config   configFile: '/Users/honghuangdc/Web/Projects/Github/soybean-admin/vite.config.ts',
  vite:config   configFileDependencies: [
  vite:config     'build/plugins/vue.ts',
  vite:config     'build/plugins/html.ts',
  vite:config     'build/plugins/iconify.ts',
  vite:config     'build/plugins/windicss.ts',
  vite:config     'build/plugins/mock.ts',
  vite:config     'build/plugins/visualizer.ts',
  vite:config     'build/plugins/index.ts',
  vite:config     'build/define/index.ts',
  vite:config     'build/index.ts',
  vite:config     'vite.config.ts'
  vite:config   ],
  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     build: {}
  vite:config   },
  vite:config   root: '/Users/honghuangdc/Web/Projects/Github/soybean-admin',
  vite:config   publicDir: '/Users/honghuangdc/Web/Projects/Github/soybean-admin/public',
  vite:config   cacheDir: '/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isProduction: true,
  vite:config   preview: {
  vite:config     port: undefined,
  vite:config     strictPort: undefined,
  vite:config     host: '0.0.0.0',
  vite:config     https: undefined,
  vite:config     open: true,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   env: {
  vite:config     VITE_APP_NAME: 'SoybeanAdmin',
  vite:config     VITE_APP_TITLE: 'Soybean管理系统',
  vite:config     VITE_APP_DESC: 'SoybeanAdmin是一个中后台管理系统模版',
  vite:config     BASE_URL: '/',
  vite:config     MODE: 'production',
  vite:config     DEV: false,
  vite:config     PROD: true
  vite:config   },
  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   optimizeDeps: {
  vite:config     esbuildOptions: { keepNames: undefined, preserveSymlinks: undefined }
  vite:config   },
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object],
  vite:config       [Object], [Object], [Object]
  vite:config     ],
  vite:config     rollupOptions: {}
  vite:config   }
  vite:config } +296ms
vite v2.8.1 building for production...
transforming (124) node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/space/index.js  vite:resolve 0.37ms /resource/loading.css -> null +0ms
✓ 124 modules transformed.
[vite:css] ENOENT: no such file or directory, stat '/resource/loading.css'
file: /Users/honghuangdc/Web/Projects/Github/soybean-admin/index.html?html-proxy&index=0.css
error during build:
Error: ENOENT: no such file or directory, stat '/resource/loading.css'
[!] Error: unfinished hook action(s) on exit:
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/spin/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/statistic/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/steps/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/switch/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/table/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/tabs/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/tag/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/thing/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/time/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/time-picker/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/timeline/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/tooltip/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/transfer/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/tree/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/tree-select/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/typography/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/upload/index.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/locales/common/zhCN.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/locales/common/zhTW.js"
(vite:load-fallback) load "/Users/honghuangdc/Web/Projects/Github/soybean-admin/node_modules/.pnpm/registry.npmmirror.com+naive-ui@2.25.2_vue@3.2.31/node_modules/naive-ui/es/locales/common/enUS.js"

Validations

ygj6 commented 2 years ago

It seems that PR #6321 introduced this bug and I am investigating and will open a new PR to fix it