Skip to content

Commit af67b4f

Browse files
committed
feat: support vite
1 parent 06d54a5 commit af67b4f

24 files changed

+88
-138
lines changed

.env.development

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
VUE_APP_NAME = WEDN.NET
2-
VUE_APP_TITLE = WEDN.NET | MAKE IT BETTER!
1+
VITE_NAME = WEDN.NET
2+
VITE_TITLE = WEDN.NET | MAKE IT BETTER!
33

4-
VUE_APP_STORAGE_PREFIX = zce_dev_
4+
VITE_STORAGE_PREFIX = zce_dev_
55

6-
VUE_APP_API_BASE = https://dashboard-server.now.sh
7-
# VUE_APP_API_BASE = http://localhost:3000
6+
VITE_API_BASE = https://dashboard-server.now.sh
7+
# VITE_API_BASE = http://localhost:3000

.env.production

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
VUE_APP_NAME = WEDN.NET
2-
VUE_APP_TITLE = WEDN.NET | MAKE IT BETTER!
1+
VITE_NAME = WEDN.NET
2+
VITE_TITLE = WEDN.NET | MAKE IT BETTER!
33

4-
VUE_APP_STORAGE_PREFIX = zce_
4+
VITE_STORAGE_PREFIX = zce_
55

6-
VUE_APP_API_BASE = https://dashboard-server.now.sh
6+
VITE_API_BASE = https://dashboard-server.now.sh

.eslintrc.js

-28
This file was deleted.

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
[![devDependency Status][devdependency-img]][devdependency-url]
88
[![Code Style][style-img]][style-url]
99

10-
> A dashboard scaffolding based on Vue.js 3.0.
10+
> A dashboard scaffolding based on Vue.js 3.0 & Vite.
1111
1212
### TODOs
1313

14+
- [x] Vite
1415
- [x] Migration deps to 3.0
1516
- [x] Basic API usage
1617
- [ ] Compatibility issues

babel.config.js

-5
This file was deleted.

public/index.html index.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
<meta name="keywords" content="vue, webpack, vuex, dashboard, scaffolding, zce, zce.me">
1111
<meta name="generator" content="https://github.com/zce/dashboard">
1212
<meta name="author" content="zce <[email protected]> (https://github.com/zce)">
13-
<link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
14-
<title><%= VUE_APP_NAME %></title>
13+
<title>Dashboard</title>
1514
</head>
1615

1716
<body>
@@ -64,7 +63,7 @@
6463
<path style="animation-delay: -0.8s" d="M69.4 28.7c-3-2.8-6.5-4.8-10.3-6-4.6-1.5-7.7-5.8-7.7-10.6V7.5c4.9.2 9.7 1.1 14.2 2.9 7.4 2.9 9.5 12.6 3.8 18.3z" />
6564
</svg>
6665
</div>
67-
<!-- built files will be auto injected -->
66+
<script type="module" src="/src/main.js"></script>
6867
</body>
6968

7069
</html>

package.json

+7-16
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
"author": "zce <[email protected]> (https://zce.me)",
2020
"main": "N/A",
2121
"scripts": {
22-
"lint": "vue-cli-service lint",
23-
"serve": "vue-cli-service serve",
24-
"build": "vue-cli-service build"
22+
"dev": "vite",
23+
"lint": "vite lint",
24+
"build": "vite build",
25+
"serve": "vite preview"
2526
},
2627
"commitlint": {
2728
"extends": [
2829
"@commitlint/config-conventional"
2930
]
3031
},
3132
"lint-staged": {
32-
"*.{js,vue}": "vue-cli-service lint"
33+
"*.{js,vue}": "vite lint"
3334
},
3435
"renovate": {
3536
"extends": [
@@ -49,21 +50,11 @@
4950
"devDependencies": {
5051
"@commitlint/cli": "12.0.1",
5152
"@commitlint/config-conventional": "12.0.1",
52-
"@vue/cli-plugin-babel": "4.5.11",
53-
"@vue/cli-plugin-eslint": "4.5.11",
54-
"@vue/cli-service": "4.5.11",
53+
"@vitejs/plugin-vue": "1.1.5",
5554
"@vue/compiler-sfc": "3.0.7",
56-
"@vue/eslint-config-standard": "6.0.0",
57-
"babel-eslint": "10.1.0",
58-
"eslint": "7.22.0",
59-
"eslint-plugin-import": "2.22.1",
60-
"eslint-plugin-node": "11.1.0",
61-
"eslint-plugin-promise": "4.3.1",
62-
"eslint-plugin-standard": "5.0.0",
63-
"eslint-plugin-vue": "7.7.0",
6455
"husky": "5.1.3",
6556
"lint-staged": "10.5.4",
6657
"sass": "1.32.8",
67-
"sass-loader": "10.1.1"
58+
"vite": "2.1.0"
6859
}
6960
}

src/components/navbar.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<script>
2424
import { mapGetters } from 'vuex'
25-
import MenuList from './menu'
25+
import MenuList from './menu.vue'
2626
2727
export default {
2828
name: 'navbar',

src/components/sidebar.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<script>
1414
import { mapGetters, mapActions } from 'vuex'
15-
import MenuList from './menu'
15+
import MenuList from './menu.vue'
1616
1717
export default {
1818
name: 'sidebar',

src/i18n/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { createI18n } from 'vue-i18n'
44
export default createI18n({
55
locale: 'en',
66
messages: {
7-
en: require('./locales/en'),
8-
cn: require('./locales/cn'),
9-
ja: require('./locales/ja')
7+
en: import('./locales/en'),
8+
cn: import('./locales/cn'),
9+
ja: import('./locales/ja')
1010
}
1111
})

src/main.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createApp } from 'vue'
22
import element from 'element-plus'
3-
import App from './app'
3+
import App from './app.vue'
44
import i18n from './i18n'
55
import store from './store'
66
import router from './router'
@@ -13,8 +13,8 @@ import './style.scss'
1313
const app = createApp(App)
1414

1515
// global config
16-
// app.config.debug = process.env.NODE_ENV === 'development'
17-
// app.config.silent = process.env.NODE_ENV === 'production'
16+
// app.config.debug = import.meta.env.DEV
17+
// app.config.silent = import.meta.env.PROD
1818
// app.config.productionTip = false
1919

2020
// plugins

src/plugins/title.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default app => {
1212
router.afterEach(route => {
1313
const current = route.matched[route.matched.length - 1].components.default
1414
const title = current[property] || current.name
15-
const items = [process.env.VUE_APP_TITLE]
15+
const items = [import.meta.env.VITE_TITLE]
1616
title && items.unshift(title)
1717

1818
// change title
@@ -26,7 +26,7 @@ export default app => {
2626
// })
2727
// .filter(t => t && t.trim())
2828
// .reverse()
29-
// document.title = [...items, process.env.VUE_APP_TITLE].join(separator)
29+
// document.title = [...items, import.meta.env.VITE_TITLE].join(separator)
3030
})
3131

3232
Object.defineProperties(app.config.globalProperties, {

src/router/demo-routes.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,67 @@ export default [
44
name: 'demo',
55
path: '/demo',
66
meta: { requireAuth: false },
7-
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/index')
7+
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/index.vue')
88
},
99
{
1010
name: 'demo-data',
1111
path: '/demo/data',
1212
meta: { requireAuth: false },
13-
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/data')
13+
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/data.vue')
1414
},
1515
{
1616
name: 'demo-vuex',
1717
path: '/demo/vuex',
1818
meta: { requireAuth: false },
19-
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/vuex')
19+
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/vuex.vue')
2020
},
2121
{
2222
name: 'demo-i18n',
2323
path: '/demo/i18n',
2424
meta: { requireAuth: false },
25-
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/i18n')
25+
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/i18n.vue')
2626
},
2727
{
2828
name: 'demo-proxy',
2929
path: '/demo/proxy',
3030
meta: { requireAuth: false },
31-
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/proxy')
31+
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/proxy.vue')
3232
},
3333
{
3434
name: 'demo-cors',
3535
path: '/demo/cors',
3636
meta: { requireAuth: false },
37-
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/cors')
37+
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/cors.vue')
3838
},
3939
{
4040
name: 'demo-params',
4141
path: '/demo/:name',
4242
meta: { requireAuth: false },
43-
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/params')
43+
component: () => import(/* webpackChunkName: 'demo' */ '../views/demo/params.vue')
4444
},
4545
// ## component views
4646
{
4747
name: 'components',
4848
path: '/components',
4949
meta: { requireAuth: false },
50-
component: () => import(/* webpackChunkName: 'components' */ '../views/demo/components/index')
50+
component: () => import(/* webpackChunkName: 'components' */ '../views/demo/components/index.vue')
5151
},
5252
{
5353
name: 'components-icons',
5454
path: '/components/icons',
5555
meta: { requireAuth: false },
56-
component: () => import(/* webpackChunkName: 'components' */ '../views/demo/components/icons')
56+
component: () => import(/* webpackChunkName: 'components' */ '../views/demo/components/icons.vue')
5757
},
5858
{
5959
name: 'components-button',
6060
path: '/components/button',
6161
meta: { requireAuth: false },
62-
component: () => import(/* webpackChunkName: 'components' */ '../views/demo/components/button')
62+
component: () => import(/* webpackChunkName: 'components' */ '../views/demo/components/button.vue')
6363
},
6464
{
6565
name: 'components-table',
6666
path: '/components/table',
6767
meta: { requireAuth: false },
68-
component: () => import(/* webpackChunkName: 'components' */ '../views/demo/components/table')
68+
component: () => import(/* webpackChunkName: 'components' */ '../views/demo/components/table.vue')
6969
}
7070
]

src/router/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import routes from './routes'
66

77
const router = createRouter({
88
history: createWebHashHistory(),
9-
base: process.env.BASE_URL,
9+
base: import.meta.env.BASE_URL,
1010
routes
1111
})
1212

0 commit comments

Comments
 (0)