vitejs / vite-plugin-vue

Vite Vue Plugins
MIT License
504 stars 155 forks source link

[vite:css-post] Plugin error - Unable to get file name for unknown file "2fa9c3fa". #174

Closed gaoliang-l closed 1 year ago

gaoliang-l commented 1 year ago

Related plugins

Describe the bug

I use legacy on vite4.2.0+@ vitejs/plugin legacy4{

targets: ['chrome 58']

}Error reported during rendering chunks

Reproduction

not have

Steps to reproduce

Run 'npm run build' :[vite:css-post] Plugin error - Unable to get file name for unknown file "2fa9c3fa". ✓ built in 7.80s error during build: RollupError: Plugin error - Unable to get file name for unknown file "2fa9c3fa". at error (file:///vite-project-platform/node_modules/rollup/dist/es/shared/node-entry.js:2128:30) at Object.FileEmitter.getFileName (file:///vite-project-platform/node_modules/rollup/dist/es/shared/node-entry.js:23972:24) at file:///vite-project-platform/node_modules/vite/dist/node/chunks/dep-79892de8.js:38026:43 at String.replace () at resolveAssetUrlsInCss (file:///vite-project-platform/node_modules/vite/dist/node/chunks/dep-79892de8.js:38025:37) at Object.renderChunk (fvite-project-platform/node_modules/vite/dist/node/chunks/dep-79892de8.js:38054:32) at file:///vite-project-platform/node_modules/rollup/dist/es/shared/node-entry.js:24395:40 at processTicksAndRejections (node:internal/process/task_queues:96:5)

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
    Memory: 2.45 GB / 15.37 GB
  Binaries:
    Node: 16.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (113.0.1774.35)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @vitejs/plugin-legacy: ^4.0.2 => 4.0.2
    @vitejs/plugin-vue: ^4.1.0 => 4.1.0
    vite: ^4.2.0 => 4.2.1

Used Package Manager

npm

Logs

No response

Validations

github-actions[bot] commented 1 year ago

Hello @gcq-z. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

gaoliang-l commented 1 year ago

import { defineConfig } from 'vite' import path from 'path' import vue from '@vitejs/plugin-vue' import AutoImport from 'unplugin-auto-import/vite' import VueComponents from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import { VantResolver } from 'unplugin-vue-components/resolvers' import UNO_CSS from 'unocss/vite' import legacy from '@vitejs/plugin-legacy'

// https://vitejs.dev/config/ export default defineConfig({ resolve: { // 设置src别名 alias: { '@': path.resolve(__dirname, 'src') } }, plugins: [ vue(), AutoImport({ imports: ['vue', 'vue-router'], resolvers: [ElementPlusResolver()], dts: 'src/auto-import.d.ts' }), VueComponents({ dts: 'src/components.d.ts', resolvers: [ElementPlusResolver(), VantResolver()] }), UNO_CSS(), legacy({ targets: ['chrome 58'] }) ], publicDir: 'public', base: './', build: { // target:['chrome 58'], rollupOptions: { output: { chunkFileNames: 'js/[name]-[hash].js', entryFileNames: 'js/[name]-[hash].js', assetFileNames: '[ext]/[name]-[hash].[ext]' } } } })