The title is rewritten as follows: Importing an index.ts file with no file extension in Vue 3 and Vite produces an error link when an index.vue file is encountered in the same folder.
<p>How to import an index.ts file using vue 3 and vite without specifying the file extension when there is another index.vue file in the same folder? </p>
<p>I'm trying to import the component: </p>
<pre class="brush:php;toolbar:false;">import { Component } from '@/app/some_component'</pre>
<pre class="brush:php;toolbar:false;">src
|
└───
app
│
└───some_component
│ index.ts
│ index.vue
│ ...</pre>
<p>But Webstorm references the index.vue file by default. </p>
<p>So, how to make Webstorm import the <strong>index.ts</strong> file by default? </p>
<p><strong>P.S.</strong> By the way, everything works fine when I build the app, it seems to be a linking issue with Webstorm.</p>
<p>这是<strong>vite.config.ts</strong>的内容</p>
<pre class="brush:php;toolbar:false;">import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import tsconfigPaths from 'vite-tsconfig-paths'
export default defineConfig({
plugins: [vue(), tsconfigPaths()],
server: {
host: true,
port: 5000,
},
preview: {
port: 8000
},
resolve: {
alias:
{
'@': path.resolve(__dirname, "./src"),
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: `
@import "@/app/styles/vars.scss";
@import "@/app/styles/mixins.scss";
`
}
}
},
})</pre>
<p>这是<strong>tsconfig.json</strong>的内容</p>
<pre class="brush:php;toolbar:false;">{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"@/*": [
"./src/*"
]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx"],
"references": [{ "path": "./tsconfig.node.json" }]
}</pre>
<p><br /></p>