build: fix test config

This commit is contained in:
Fine 2022-12-15 11:33:32 +08:00
parent 09d0d0049b
commit 30317aabc0
2 changed files with 21 additions and 5 deletions

View File

@ -0,0 +1,17 @@
import { describe, it, expect } from "vitest";
// import { mount } from '@vue/test-utils'
// import HelloWorld from '../HelloWorld.vue'
// describe('HelloWorld', () => {
// it('renders properly', () => {
// const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
// expect(wrapper.text()).toContain('Hello Vitest')
// })
// })
describe("My First Test", () => {
it("renders props.msg when passed", () => {
const msg = "new message";
console.log(msg);
});
});

View File

@ -28,6 +28,7 @@ import path from "path";
const OUTPUT_DIR = "dist"; const OUTPUT_DIR = "dist";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default ({ command, mode }: ConfigEnv): UserConfig => { export default ({ command, mode }: ConfigEnv): UserConfig => {
const { VITE_SW_PROXY_TARGET } = loadEnv(mode, process.cwd());
return { return {
plugins: [ plugins: [
vue(), vue(),
@ -36,11 +37,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
AutoImport({ AutoImport({
imports: ["vue"], imports: ["vue"],
resolvers: [ElementPlusResolver()], resolvers: [ElementPlusResolver()],
dts: "./src/types/auto-imports.d.ts", dts: path.resolve(__dirname, "./src/types/auto-imports.d.ts"),
}), }),
Components({ Components({
resolvers: [ElementPlusResolver()], resolvers: [ElementPlusResolver()],
dts: "./src/types/components.d.ts", dts: path.resolve(__dirname, "./src/types/components.d.ts"),
}), }),
], ],
resolve: { resolve: {
@ -56,9 +57,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
port: 3000, port: 3000,
proxy: { proxy: {
"/graphql": { "/graphql": {
target: `${ target: `${VITE_SW_PROXY_TARGET || "http://127.0.0.1:12800"}`,
loadEnv(mode, process.cwd()).VITE_SW_PROXY_TARGET || "http://127.0.0.1:12800"
}`,
changeOrigin: true, changeOrigin: true,
}, },
}, },