feat: 项目搭建
This commit is contained in:
parent
7ecf456eb6
commit
63368aa1f6
4
.husky/commit-msg
Normal file
4
.husky/commit-msg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
. "$(dirname -- "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
npx --no-install commitlint --edit $1
|
||||||
14
.vscode/extensions.json
vendored
Normal file
14
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"vue.volar",
|
||||||
|
"vue.vscode-typescript-vue-plugin",
|
||||||
|
"hollowtree.vue-snippets",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"stylelint.vscode-stylelint",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"editorconfig.editorconfig",
|
||||||
|
"streetsidesoftware.code-spell-checker",
|
||||||
|
"syler.sass-indented",
|
||||||
|
"mikestead.dotenv"
|
||||||
|
]
|
||||||
|
}
|
||||||
132
.vscode/settings.json
vendored
Normal file
132
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"stylelint.enable": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.stylelint": true
|
||||||
|
},
|
||||||
|
"stylelint.validate": ["css", "less", "postcss", "scss", "vue", "sass", "html"],
|
||||||
|
"files.eol": "\n",
|
||||||
|
"[vue]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[typescript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[json]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[jsonc]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[typescriptreact]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[scss]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[html]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[markdown]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[less]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"cSpell.words": [
|
||||||
|
"acroutes",
|
||||||
|
"adcode",
|
||||||
|
"Alipay",
|
||||||
|
"AMAP",
|
||||||
|
"Anglar",
|
||||||
|
"antd",
|
||||||
|
"apng",
|
||||||
|
"Biao",
|
||||||
|
"bottomleft",
|
||||||
|
"bottomright",
|
||||||
|
"breakline",
|
||||||
|
"browserslist",
|
||||||
|
"cascader",
|
||||||
|
"cnpm",
|
||||||
|
"commitize",
|
||||||
|
"commitlint",
|
||||||
|
"contentleft",
|
||||||
|
"contentright",
|
||||||
|
"CSDN",
|
||||||
|
"curveness",
|
||||||
|
"daterange",
|
||||||
|
"datetimerange",
|
||||||
|
"doclock",
|
||||||
|
"dragover",
|
||||||
|
"easymock",
|
||||||
|
"echarts",
|
||||||
|
"esbuild",
|
||||||
|
"fangda",
|
||||||
|
"fastmock",
|
||||||
|
"Geeker",
|
||||||
|
"Gitee",
|
||||||
|
"glgview",
|
||||||
|
"hexs",
|
||||||
|
"iconfont",
|
||||||
|
"Jheng",
|
||||||
|
"juejin",
|
||||||
|
"liquidfill",
|
||||||
|
"liutao",
|
||||||
|
"loglevel",
|
||||||
|
"longpress",
|
||||||
|
"malefemale",
|
||||||
|
"Mapchart",
|
||||||
|
"nprogress",
|
||||||
|
"officedocument",
|
||||||
|
"openxmlformats",
|
||||||
|
"pageable",
|
||||||
|
"Parens",
|
||||||
|
"persistedstate",
|
||||||
|
"Pinia",
|
||||||
|
"pjpeg",
|
||||||
|
"Prefixs",
|
||||||
|
"protable",
|
||||||
|
"singleline",
|
||||||
|
"sortablejs",
|
||||||
|
"sousuo",
|
||||||
|
"spreadsheetml",
|
||||||
|
"styl",
|
||||||
|
"stylelint",
|
||||||
|
"stylelintignore",
|
||||||
|
"stylelintrc",
|
||||||
|
"suoxiao",
|
||||||
|
"sysmbol",
|
||||||
|
"timerange",
|
||||||
|
"topleft",
|
||||||
|
"topright",
|
||||||
|
"truetype",
|
||||||
|
"Uncapitalize",
|
||||||
|
"unplugin",
|
||||||
|
"unref",
|
||||||
|
"vite",
|
||||||
|
"vuedraggable",
|
||||||
|
"vueuse",
|
||||||
|
"Vuex",
|
||||||
|
"wangeditor",
|
||||||
|
"Wechat",
|
||||||
|
"xianxingdaoyu",
|
||||||
|
"xianxingdiqiu",
|
||||||
|
"xianxingditu",
|
||||||
|
"xianxingfanchuan",
|
||||||
|
"xianxingfeiji",
|
||||||
|
"xianxinglvhangriji",
|
||||||
|
"xianxingtianqiyubao",
|
||||||
|
"xianxingxiangjipaizhao",
|
||||||
|
"xianxingxiarilengyin",
|
||||||
|
"xianxingyoulun",
|
||||||
|
"xianxingzijiayou",
|
||||||
|
"xiaoxi",
|
||||||
|
"yxxx",
|
||||||
|
"zhongyingwen",
|
||||||
|
"zhuti",
|
||||||
|
"zlevel"
|
||||||
|
]
|
||||||
|
}
|
||||||
28012
package-lock.json
generated
Normal file
28012
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
postcss.config.js
Normal file
20
postcss.config.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// module.exports = {
|
||||||
|
// plugins: {
|
||||||
|
// autoprefixer: {
|
||||||
|
// overrideBrowserslist: [
|
||||||
|
// "Android 4.1",
|
||||||
|
// "iOS 7.1",
|
||||||
|
// "Chrome > 31",
|
||||||
|
// "ff > 31",
|
||||||
|
// "ie >= 8",
|
||||||
|
// "last 10 versions" // 所有主流浏览器最近10版本用
|
||||||
|
// ],
|
||||||
|
// grid: true
|
||||||
|
// },
|
||||||
|
// "postcss-pxtorem": {
|
||||||
|
// rootValue: 192, // 设计稿宽度的1/ 10
|
||||||
|
// propList: ["*", "!border"], // 除 border 外所有px 转 rem
|
||||||
|
// selectorBlackList: [".el-"] // 过滤掉.el-开头的class,不进行rem转换
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
38
tsconfig.json
Normal file
38
tsconfig.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "esnext",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
// element 类型提示
|
||||||
|
// "types": ["element-plus/global"],
|
||||||
|
|
||||||
|
/* Strict Type-Checking Options */
|
||||||
|
"strict": true /* Enable all strict type-checking options. */,
|
||||||
|
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||||
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
|
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||||
|
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||||
|
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||||
|
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||||
|
|
||||||
|
"jsx": "preserve",
|
||||||
|
"sourceMap": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
// 跳过第三方库检查,解决打包失败
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"lib": ["esnext", "dom"],
|
||||||
|
// 解析非相对模块名的基准目录
|
||||||
|
"baseUrl": "./",
|
||||||
|
// 模块名到基于 baseUrl 的路径映射的列表。
|
||||||
|
"paths": {
|
||||||
|
"@": ["src"],
|
||||||
|
"@/*": ["src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "vite.config.ts"],
|
||||||
|
"exclude": ["node_modules", "dist", "**/*.js"]
|
||||||
|
}
|
||||||
150
vite.config.ts
Normal file
150
vite.config.ts
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
import { defineConfig, loadEnv, ConfigEnv, UserConfig } from "vite";
|
||||||
|
import { createHtmlPlugin } from "vite-plugin-html";
|
||||||
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import { resolve } from "path";
|
||||||
|
import { wrapperEnv } from "./src/utils/getEnv";
|
||||||
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
|
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
|
||||||
|
import viteCompression from "vite-plugin-compression";
|
||||||
|
import vueSetupExtend from "vite-plugin-vue-setup-extend-plus";
|
||||||
|
import eslintPlugin from "vite-plugin-eslint";
|
||||||
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
|
import importToCDN from "vite-plugin-cdn-import";
|
||||||
|
// import AutoImport from "unplugin-auto-import/vite";
|
||||||
|
// import Components from "unplugin-vue-components/vite";
|
||||||
|
// import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
|
||||||
|
import { vitePluginMars3d } from "vite-plugin-mars3d";
|
||||||
|
// @see: https://vitejs.dev/config/
|
||||||
|
// export const BASE_IMAGE_URL = import.meta.env.NODE_ENV === "development" ? "./src" : "";
|
||||||
|
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
||||||
|
const env = loadEnv(mode, process.cwd());
|
||||||
|
const viteEnv = wrapperEnv(env);
|
||||||
|
|
||||||
|
return {
|
||||||
|
base: "./",
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"@": resolve(__dirname, "./src"),
|
||||||
|
"vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
css: {
|
||||||
|
preprocessorOptions: {
|
||||||
|
scss: {
|
||||||
|
additionalData: `@import "@/styles/var.scss";`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
// 服务器主机名,如果允许外部访问,可设置为 "0.0.0.0"
|
||||||
|
host: "0.0.0.0",
|
||||||
|
port: viteEnv.VITE_PORT,
|
||||||
|
open: viteEnv.VITE_OPEN,
|
||||||
|
cors: true,
|
||||||
|
// 跨域代理配置
|
||||||
|
proxy: {
|
||||||
|
"/api": {
|
||||||
|
target: viteEnv.VITE_API_URL, // easymock
|
||||||
|
// target: "https://www.fastmock.site/mock/f81e8333c1a9276214bcdbc170d9e0a0", // fastmock
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: path => path.replace(/^\/api/, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// open: true,
|
||||||
|
// host: "localhost",
|
||||||
|
// port: 8520,
|
||||||
|
// //这里的ip和端口是前端项目的;下面为需要跨域访问后端项目
|
||||||
|
// proxy: {
|
||||||
|
// "^/token": {
|
||||||
|
// target: "http://192.168.34.155:8520/", //这里填入你要请求的接口的前缀
|
||||||
|
// ws: true, //代理websocket
|
||||||
|
// changeOrigin: true, //虚拟的站点需要更管origin
|
||||||
|
// secure: true, //是否https接口
|
||||||
|
// rewrite: path => path.replace(/^\/api/, "")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
vue(),
|
||||||
|
vitePluginMars3d(),
|
||||||
|
createHtmlPlugin({
|
||||||
|
inject: {
|
||||||
|
data: {
|
||||||
|
title: viteEnv.VITE_GLOB_APP_TITLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// * 使用 svg 图标
|
||||||
|
createSvgIconsPlugin({
|
||||||
|
iconDirs: [resolve(process.cwd(), "src/assets/icons")],
|
||||||
|
symbolId: "icon-[dir]-[name]"
|
||||||
|
}),
|
||||||
|
// * EsLint 报错信息显示在浏览器界面上
|
||||||
|
// eslintPlugin(),
|
||||||
|
// * vite 可以使用 jsx/tsx 语法
|
||||||
|
vueJsx(),
|
||||||
|
// * name 可以写在 script 标签上
|
||||||
|
vueSetupExtend(),
|
||||||
|
// * 是否生成包预览(分析依赖包大小,方便做优化处理)
|
||||||
|
viteEnv.VITE_REPORT && visualizer(),
|
||||||
|
// * gzip compress
|
||||||
|
viteEnv.VITE_BUILD_GZIP &&
|
||||||
|
viteCompression({
|
||||||
|
verbose: true,
|
||||||
|
disable: false,
|
||||||
|
threshold: 10240,
|
||||||
|
algorithm: "gzip",
|
||||||
|
ext: ".gz"
|
||||||
|
}),
|
||||||
|
// * cdn 引入(vue按需引入会导致依赖vue的插件出现问题(列如:pinia/vuex))
|
||||||
|
importToCDN({
|
||||||
|
modules: [
|
||||||
|
// {
|
||||||
|
// name: "vue",
|
||||||
|
// var: "Vue",
|
||||||
|
// path: "https://unpkg.com/vue@next"
|
||||||
|
// },
|
||||||
|
// 使用cdn引入element-plus时,开发环境还是需要在main.js中引入element-plus,可以不用引入css
|
||||||
|
// {
|
||||||
|
// name: "element-plus",
|
||||||
|
// var: "ElementPlus",
|
||||||
|
// path: "https://unpkg.com/element-plus",
|
||||||
|
// css: "https://unpkg.com/element-plus/dist/index.css"
|
||||||
|
// }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
// * demand import element
|
||||||
|
// AutoImport({
|
||||||
|
// resolvers: [ElementPlusResolver()]
|
||||||
|
// }),
|
||||||
|
// Components({
|
||||||
|
// resolvers: [ElementPlusResolver()]
|
||||||
|
// }),
|
||||||
|
],
|
||||||
|
// * 打包去除 console.log && debugger
|
||||||
|
esbuild: {
|
||||||
|
pure: viteEnv.VITE_DROP_CONSOLE ? ["console.log", "debugger"] : []
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
outDir: "dist",
|
||||||
|
minify: "esbuild",
|
||||||
|
// esbuild 打包更快,但是不能去除 console.log,terser打包慢,但能去除 console.log
|
||||||
|
// minify: "terser",
|
||||||
|
// terserOptions: {
|
||||||
|
// compress: {
|
||||||
|
// drop_console: viteEnv.VITE_DROP_CONSOLE,
|
||||||
|
// drop_debugger: true
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
chunkSizeWarningLimit: 2500,
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
// Static resource classification and packaging
|
||||||
|
chunkFileNames: "assets/js/[name]-[hash].js",
|
||||||
|
entryFileNames: "assets/js/[name]-[hash].js",
|
||||||
|
assetFileNames: "assets/[ext]/[name]-[hash].[ext]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user