feat-vite配置resolve.alias

This commit is contained in:
h_mo 2022-06-03 10:11:20 +08:00
parent f9aea4253f
commit a95275e3ad
5 changed files with 58 additions and 13 deletions

View File

@ -53,6 +53,7 @@
"@dcloudio/uni-automator": "3.0.0-alpha-3040820220424001",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3040820220424001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-3040820220424001",
"@types/node": "^17.0.38",
"sass": "^1.52.1",
"typescript": "^4.6.3",
"vite": "^2.9.6",

40
pnpm-lock.yaml generated
View File

@ -18,6 +18,8 @@ specifiers:
'@dcloudio/uni-mp-weixin': 3.0.0-alpha-3040820220424001
'@dcloudio/uni-quickapp-webview': 3.0.0-alpha-3040820220424001
'@dcloudio/vite-plugin-uni': 3.0.0-alpha-3040820220424001
'@types/node': ^17.0.38
sass: ^1.52.1
typescript: ^4.6.3
vite: ^2.9.6
vite-plugin-windicss: ^1.8.4
@ -46,8 +48,10 @@ devDependencies:
'@dcloudio/uni-automator': registry.npmmirror.com/@dcloudio/uni-automator/3.0.0-alpha-3040820220424001_vue@3.2.36
'@dcloudio/uni-cli-shared': registry.npmmirror.com/@dcloudio/uni-cli-shared/3.0.0-alpha-3040820220424001_vue@3.2.36
'@dcloudio/vite-plugin-uni': registry.npmmirror.com/@dcloudio/vite-plugin-uni/3.0.0-alpha-3040820220424001_vite@2.9.9+vue@3.2.36
'@types/node': registry.npmmirror.com/@types/node/17.0.38
sass: registry.npmmirror.com/sass/1.52.1
typescript: registry.npmmirror.com/typescript/4.7.2
vite: registry.npmmirror.com/vite/2.9.9
vite: registry.npmmirror.com/vite/2.9.9_sass@1.52.1
vite-plugin-windicss: registry.npmmirror.com/vite-plugin-windicss/1.8.4_vite@2.9.9
packages:
@ -938,7 +942,7 @@ packages:
hash-sum: registry.npmmirror.com/hash-sum/2.0.0
jsonc-parser: registry.npmmirror.com/jsonc-parser/3.0.0
picocolors: registry.npmmirror.com/picocolors/1.0.0
vite: registry.npmmirror.com/vite/2.9.9
vite: registry.npmmirror.com/vite/2.9.9_sass@1.52.1
transitivePeerDependencies:
- postcss
- supports-color
@ -1156,6 +1160,12 @@ packages:
estree-walker: registry.npmmirror.com/estree-walker/2.0.2
picomatch: registry.npmmirror.com/picomatch/2.3.1
registry.npmmirror.com/@types/node/17.0.38:
resolution: {integrity: sha512-5jY9RhV7c0Z4Jy09G+NIDTsCZ5G0L5n+Z+p+Y7t5VJHM30bgwzSjVtlcBxqAj+6L/swIlvtOSzr8rBk/aNyV2g==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/node/-/node-17.0.38.tgz}
name: '@types/node'
version: 17.0.38
dev: true
registry.npmmirror.com/@vitejs/plugin-legacy/1.8.2_vite@2.9.9:
resolution: {integrity: sha512-NCOKU+pU+cxLMR9P9RTolEuOK+h+zYBXlknj+zGcKSj/NXBZYgA1GAH1FnO4zijoWRiTaiOm2ha9LQrELE7XHg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@vitejs/plugin-legacy/-/plugin-legacy-1.8.2.tgz}
id: registry.npmmirror.com/@vitejs/plugin-legacy/1.8.2
@ -1170,7 +1180,7 @@ packages:
magic-string: registry.npmmirror.com/magic-string/0.26.2
regenerator-runtime: registry.npmmirror.com/regenerator-runtime/0.13.9
systemjs: registry.npmmirror.com/systemjs/6.12.1
vite: registry.npmmirror.com/vite/2.9.9
vite: registry.npmmirror.com/vite/2.9.9_sass@1.52.1
dev: true
registry.npmmirror.com/@vitejs/plugin-vue-jsx/1.3.10:
@ -1199,7 +1209,7 @@ packages:
vite: ^2.5.10
vue: ^3.2.25
dependencies:
vite: registry.npmmirror.com/vite/2.9.9
vite: registry.npmmirror.com/vite/2.9.9_sass@1.52.1
vue: registry.npmmirror.com/vue/3.2.36
registry.npmmirror.com/@vivaxy/wxml/2.1.0:
@ -2353,6 +2363,11 @@ packages:
peerDependencies:
postcss: ^8.1.0
registry.npmmirror.com/immutable/4.1.0:
resolution: {integrity: sha512-oNkuqVTA8jqG1Q6c+UglTOD1xhC1BtjKI7XkCXRkZHrN5m18/XsnUp8Q89GkQO/z+0WjonSvl0FLhDYftp46nQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/immutable/-/immutable-4.1.0.tgz}
name: immutable
version: 4.1.0
registry.npmmirror.com/inherits/2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz}
name: inherits
@ -2995,6 +3010,17 @@ packages:
version: 2.1.2
dev: true
registry.npmmirror.com/sass/1.52.1:
resolution: {integrity: sha512-fSzYTbr7z8oQnVJ3Acp9hV80dM1fkMN7mSD/25mpcct9F7FPBMOI8krEYALgU1aZoqGhQNhTPsuSmxjnIvAm4Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/sass/-/sass-1.52.1.tgz}
name: sass
version: 1.52.1
engines: {node: '>=12.0.0'}
hasBin: true
dependencies:
chokidar: registry.npmmirror.com/chokidar/3.5.3
immutable: registry.npmmirror.com/immutable/4.1.0
source-map-js: registry.npmmirror.com/source-map-js/1.0.2
registry.npmmirror.com/semver/6.3.0:
resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/semver/-/semver-6.3.0.tgz}
name: semver
@ -3238,14 +3264,15 @@ packages:
'@windicss/plugin-utils': registry.npmmirror.com/@windicss/plugin-utils/1.8.4
debug: registry.npmmirror.com/debug/4.3.4
kolorist: registry.npmmirror.com/kolorist/1.5.1
vite: registry.npmmirror.com/vite/2.9.9
vite: registry.npmmirror.com/vite/2.9.9_sass@1.52.1
windicss: registry.npmmirror.com/windicss/3.5.4
transitivePeerDependencies:
- supports-color
dev: true
registry.npmmirror.com/vite/2.9.9:
registry.npmmirror.com/vite/2.9.9_sass@1.52.1:
resolution: {integrity: sha512-ffaam+NgHfbEmfw/Vuh6BHKKlI/XIAhxE5QSS7gFLIngxg171mg1P3a4LSRME0z2ZU1ScxoKzphkipcYwSD5Ew==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/vite/-/vite-2.9.9.tgz}
id: registry.npmmirror.com/vite/2.9.9
name: vite
version: 2.9.9
engines: {node: '>=12.2.0'}
@ -3266,6 +3293,7 @@ packages:
postcss: registry.npmmirror.com/postcss/8.4.14
resolve: registry.npmmirror.com/resolve/1.22.0
rollup: registry.npmmirror.com/rollup/2.75.5
sass: registry.npmmirror.com/sass/1.52.1
optionalDependencies:
fsevents: registry.npmmirror.com/fsevents/2.3.2

View File

@ -0,0 +1,14 @@
<template>
Test Component
</template>
<script lang="ts">
import {defineComponent} from 'vue';
export default defineComponent({
name: 'Test',
setup() {
}
});
</script>
<style scoped lang="scss"></style>

View File

@ -4,18 +4,17 @@
<view class="text-area bg-rose-500 h-30rpx p-20rpx red" >
<text class="">{{ title }}</text>
</view>
<Test />
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import Test from "@/components/test/Test.vue";
const title = ref('Hello')
</script>
<style lang="scss">
.red{
//color: green;
}
.content {
display: flex;
flex-direction: column;
@ -26,10 +25,7 @@ const title = ref('Hello')
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
margin: 200rpx auto 50rpx;
}
.text-area {

View File

@ -2,6 +2,7 @@ import {defineConfig} from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import windicss from 'vite-plugin-windicss';
import MiniProgramTailwind from '@dcasia/mini-program-tailwind-webpack-plugin/rollup';
import { resolve } from 'path';
// https://vitejs.dev/config/
export default defineConfig({
@ -15,4 +16,9 @@ export default defineConfig({
designWidth: 350
}),
],
resolve: {
alias: {
'@': resolve('./src'),
},
},
});