npm create vite@latest vue-vite-ts -- --template vue-ts。npm i,启动服务npm run dev。vite.config.ts 中的配置,defineConfig.server选项。
js
export default defineConfig({
server: {
hmr: true,
port: 9074,
open: true,
},
});
npm install vue-router@4,使用HTML5模式。
在src路径下新建router文件夹,在main.ts中加载注册使用。npm install element-plus --save。
在main.ts中引用使用。
> import 'element-plus/dist/index.css'
> import 'element-plus/theme-chalk/dark/css-vars.css'npm install pinia --save。
在main.ts中加载注册使用。npm install sass --savejs
import topLevelAwait from 'vite-plugin-top-level-await'
export default defineConfig({
plugins: [
topLevelAwait({
// The export name of top-level await promise for each chunk module
promiseExportName: '__tla',
// The function to generate import names of top-level await promise in each chunk module
promiseImportName: i => `__tla_${i}`
})
]
});
animate.css, axios,driver.js,qs,vite-plugin-svg-icons,fast-glob ...vite.config.ts中配置defineConfig.css选项。js
export default defineConfig({
css:{
preprocessorOptions:{
scss:{
additionalData:`@use "./src/assets/style/index.scss";`
}
},
},
});