Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ladle not flow vite / tsconfig alias path #69

Closed
tsingson opened this issue Mar 23, 2022 · 1 comment
Closed

ladle not flow vite / tsconfig alias path #69

tsingson opened this issue Mar 23, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@tsingson
Copy link

errro info like:

[plugin:vite:import-analysis] Failed to resolve import "@/config/config" from "src/apktype/hooks/asyncApktypeAction.ts". Does the file exist?
[/Users/qin.....................e/hooks/asyncApktypeAction.ts:6:0]()
3  |  import request from "umi-request";
4  |  import { getApktpeListApi } from "./hooks";
5  |  import { baseURL } from "@/config/config";
   |                           ^
6  |  const oneAtom = atom(false);
7  |  export const asyncApktypeAction = () => {
....

tsconfig

{
  "compilerOptions": {
    "target": "ESNext",
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "types": ["vite/client", "node"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "baseUrl": ".",
    "paths": {
      "*": ["node_modules/*"],
      "@/*": ["src/*"]
    }
  },
  "include": ["src", "vite.config.ts", "cypress"]
}

vite config

import react from "@vitejs/plugin-react";
import { resolve } from "path";
import { visualizer } from "rollup-plugin-visualizer";
import { UserConfig } from "vite";
import Checker from "vite-plugin-checker";

function pathResolve(dir: string) {
  return resolve(__dirname, ".", dir);
}

const shouldAnalyze = process.env.ANALYZE;

const config: UserConfig = {
  resolve: {
    alias: [
      {
        find: /@\//,
        replacement: pathResolve("src") + "/"
      }
    ]
  },
  build: {
    rollupOptions: {
      plugins: !!shouldAnalyze ? [visualizer({ open: true, filename: "./bundle-size/bundle.html" })] : []
    },
    sourcemap: !!shouldAnalyze
  },
  css:{
    preprocessorOptions:{
      less: {
        javascriptEnabled: true,
      }
    }

  },
  plugins: [
    react({}),
    Checker({
      typescript: true,
      overlay: true,
      eslint: {
        files: "src",
        extensions: [".ts", ".tsx"]
      }
    })
  ],
};

const getConfig = () => config;

export default getConfig;

it's a bug ?

@tajo tajo added the duplicate This issue or pull request already exists label Mar 23, 2022
@tajo
Copy link
Owner

tajo commented Mar 23, 2022

duplicate #59

@tajo tajo closed this as completed Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants