Browse Source

feat: 新增 preview 模式,修改打包后路径指向

奔跑的面条 3 years ago
parent
commit
db815661e8
3 changed files with 7 additions and 1 deletions
  1. 5 0
      Makefile
  2. 1 0
      package.json
  3. 1 1
      vite.config.ts

+ 5 - 0
Makefile

@@ -6,15 +6,20 @@ dev:
 dist:
 	npm run build
 
+view:
+	npm run preview
+
 lint:
 	npm run lint
 
 new:
 	npm run new
 
+
 	
 help:
 	@echo "    make dev [npm run dev] 开发模式"
 	@echo "    make dist [npm run build] 编译模式"
+	@echo "    make view [npm run preview] 预览打包文件"
 	@echo "    make new [npm run lint] 通过自动化流程创建代码"
 	@echo "    make lint [npm run new] 格式校验"

+ 1 - 0
package.json

@@ -4,6 +4,7 @@
   "scripts": {
     "dev": "vite --host",
     "build": "vue-tsc --noEmit && vite build",
+    "preview": "vite preview",
     "new": "plop --plopfile ./plop/plopfile.js",
     "postinstall": "husky install"
   },

+ 1 - 1
vite.config.ts

@@ -11,7 +11,7 @@ function pathResolve(dir: string) {
 }
 
 export default ({ mode }) => defineConfig({
-  base: process.env.NODE_ENV === 'production' ? './' : '/',
+  base: process.env.NODE_ENV === 'production' ? '/' : '/',
   // 路径重定向
   resolve: {
     alias: [