Commit 7151765d by Jaxon

chron: 项目基础优化 与 vant2 组件库的 主题定制

1 parent 23a36dcd
// 获取 VUE_APP_ENV 非 NODE_ENV,测试环境依然 console // 获取 VUE_APP_ENV 非 NODE_ENV,测试环境依然 console
const IS_PROD = ['production', 'prod'].includes(process.env.VUE_APP_ENV) const IS_PROD = ["production", "prod"].includes(process.env.VUE_APP_ENV);
const plugins = [ const plugins = [
[ [
'import', "import",
{ {
libraryName: 'vant', libraryName: "vant",
libraryDirectory: 'es', libraryDirectory: "es",
style: true style: name => `${name}/style/less`,
}, },
'vant' "vant",
] ],
] ];
// 去除 console.log // 去除 console.log
if (IS_PROD) { if (IS_PROD) {
plugins.push('transform-remove-console') plugins.push("transform-remove-console");
} }
module.exports = { module.exports = {
presets: [['@vue/cli-plugin-babel/preset', { useBuiltIns: 'usage', corejs: 3 }]], presets: [["@vue/cli-plugin-babel/preset", { useBuiltIns: "usage", corejs: 3 }]],
plugins plugins,
} };
...@@ -99,9 +99,8 @@ export default antfu({ ...@@ -99,9 +99,8 @@ export default antfu({
order: [ order: [
"DEFINITION", // is "DEFINITION", // is
"LIST_RENDERING", // v-for "LIST_RENDERING", // v-for
"UNIQUE", // ref key
"CONDITIONALS", // v-if v-else-if v-else v-show v-cloak "CONDITIONALS", // v-if v-else-if v-else v-show v-cloak
"UNIQUE", // ref key
"RENDER_MODIFIERS", // v-once v-pre "RENDER_MODIFIERS", // v-once v-pre
"GLOBAL", // id "GLOBAL", // id
"SLOT", // v-slot slot "SLOT", // v-slot slot
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
"babel-plugin-transform-remove-console": "^6.9.4", "babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^9.39.2", "eslint": "^9.39.2",
"eslint-plugin-format": "^1.2.0", "eslint-plugin-format": "^1.2.0",
"less": "^4.6.4",
"less-loader": "^7.3.0",
"postcss-px-to-viewport": "^1.1.1", "postcss-px-to-viewport": "^1.1.1",
"sass": "^1.99.0", "sass": "^1.99.0",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
......
@primary-color: var(--themeColor, #3975c6);
@tabs-default-color: @primary-color;
...@@ -13,7 +13,7 @@ import store from "./store"; ...@@ -13,7 +13,7 @@ import store from "./store";
import { bus, store as local, tools, util } from "./utils"; import { bus, store as local, tools, util } from "./utils";
import "@/assets/css/index.scss"; import "@/assets/css/index.scss";
import "./utils/util"; import "./utils/util";
import "components"; import "@/components";
// import mixin from './mixins/index' // import mixin from './mixins/index'
vant(Vue); vant(Vue);
Vue.prototype.api = ssoApi; Vue.prototype.api = ssoApi;
......
import { util } from "utils"; import { util } from "@/utils";
import api from "../api/baseApi"; import api from "../api/baseApi";
export default { export default {
......
...@@ -22,7 +22,7 @@ Object.keys(pages).map((parent) => { ...@@ -22,7 +22,7 @@ Object.keys(pages).map((parent) => {
if (meta && meta.keepAlive) if (meta && meta.keepAlive)
keepAlives.push(name); keepAlives.push(name);
const route = { const route = {
component: resolve => require([`views/${childrenPath}.vue`], resolve), component: resolve => require([`@/views/${childrenPath}.vue`], resolve),
path, path,
name, name,
meta, meta,
......
import { Http } from "glsx-common"; import { Http } from "glsx-common";
import { util } from "utils";
import { Notify } from "vant"; import { Notify } from "vant";
import { ssoApi } from "@/api"; import { ssoApi } from "@/api";
import reportTrackFunMixin from "@/mixins/reportTrackFunMixin"; import reportTrackFunMixin from "@/mixins/reportTrackFunMixin";
import { util } from "@/utils";
const state = { const state = {
showWindow: false, showWindow: false,
......
...@@ -65,6 +65,14 @@ module.exports = { ...@@ -65,6 +65,14 @@ module.exports = {
extract: IS_PROD, extract: IS_PROD,
sourceMap: false, sourceMap: false,
loaderOptions: { loaderOptions: {
less: {
lessOptions: {
modifyVars: {
// 直接覆盖变量
hack: `true; @import "${path.resolve(__dirname, "./src/assets/css/vant-theme.less")}";`,
},
},
},
scss: { scss: {
// 向全局sass样式传入共享的全局变量, $src可以配置图片cdn前缀 // 向全局sass样式传入共享的全局变量, $src可以配置图片cdn前缀
// 详情: https://cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders // 详情: https://cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders
...@@ -125,6 +133,12 @@ module.exports = { ...@@ -125,6 +133,12 @@ module.exports = {
// 别名 alias // 别名 alias
config.resolve.alias config.resolve.alias
.set("@", resolve("src")); .set("@", resolve("src"));
// .set('assets', resolve('src/assets'))
// .set('api', resolve('src/api'))
// .set('views', resolve('src/views'))
// .set('components', resolve('src/components'))
// .set('plugins', resolve('src/components'))
// .set('utils', resolve('src/utils'))
/** /**
* 设置保留空格 * 设置保留空格
*/ */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!