Closed dramaPainter closed 4 months ago
使用vite编译成功后,拿到生产环境去运行,发现页面的样式都是乱的。结果我去查才发现根本就没有加载picker的样式,我只能使用 import "vue3-picker/dist/index.css"; 手动导入才可以,不仅提示有个文件没有生成出来,而且还有JS会报错: 这一段代码try会抛异常。仅管catch了不会报错。但是会提示有个文件没有加载成功,提示404, index-a25d2d4c.js:2825 GET https://wwww.xxx.com/assets/index-445dc627.js net::ERR_ABORTED 404 (Not Found), 麻烦看看怎么解决。
vite.config.ts
import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import Legacy from "@vitejs/plugin-legacy"; import AutoImport from "unplugin-auto-import/vite"; // @ts-ignore import Components from "unplugin-vue-components/vite"; // @ts-ignore import { NaiveUiResolver } from "unplugin-vue-components/resolvers"; // https://vitejs.dev/config/ // https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue(), Legacy({ targets: ["defaults", "not IE 11"], additionalLegacyPolyfills: ["regenerator-runtime/runtime"], }), AutoImport({ imports: ["vue", { "naive-ui": [] }], dts: "auto-imports.d.ts", }), Components({ resolvers: [NaiveUiResolver()], }), ], resolve: { dedupe: ["vue"], }, });
package.json
{ "name": "client", "private": true, "version": "1.0.0", "type": "module", "scripts": { "client-dev": "vite --port 3061 --host", "client-build": "vite build" }, "dependencies": { "@stomp/stompjs": "^6.1.2", "@vicons/antd": "^0.12.0", "axios": "^1.3.2", "echarts": "^5.4.2", "sockjs-client": "^1.6.1", "vue": "^3.2.45", "vue-router": "^4.0.14", "vue3-picker": "^0.4.3", "vue3-qr-reader": "^1.0.0" }, "devDependencies": { "@vitejs/plugin-legacy": "^3.0.1", "@vitejs/plugin-vue": "^4.0.0", "naive-ui": "^2.34.3", "typescript": "^4.9.3", "unplugin-auto-import": "^0.12.2", "unplugin-vue-components": "^0.24.1", "vite": "^4.0.0", "vue-tsc": "^1.0.11" }, "prettier": { "tabWidth": 4, "singleQuote": false, "htmlWhitespaceSensitivity": "css", "printWidth": 980, "semi": true, "bracketSpacing": true } }
您好, 請問 development 環境是正常的嗎?
使用vite编译成功后,拿到生产环境去运行,发现页面的样式都是乱的。结果我去查才发现根本就没有加载picker的样式,我只能使用 import "vue3-picker/dist/index.css"; 手动导入才可以,不仅提示有个文件没有生成出来,而且还有JS会报错: 这一段代码try会抛异常。仅管catch了不会报错。但是会提示有个文件没有加载成功,提示404, index-a25d2d4c.js:2825 GET https://wwww.xxx.com/assets/index-445dc627.js net::ERR_ABORTED 404 (Not Found), 麻烦看看怎么解决。
vite.config.ts
package.json