Skip to content

Commit 0cb953c

Browse files
committed
migrate to vite
1 parent 5728f2f commit 0cb953c

File tree

9 files changed

+4701
-25263
lines changed

9 files changed

+4701
-25263
lines changed

.eslintrc.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
module.exports = {
22
root: true,
33
env: {
4-
node: true,
4+
es2021: true,
55
},
66
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
7-
parserOptions: {
8-
parser: "babel-eslint",
9-
},
107
rules: {
118
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
129
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
10+
"vue/multi-word-component-names" : "off"
1311
},
1412
};

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ npm install
77

88
### Compiles and hot-reloads for development
99
```
10-
npm run serve
10+
npm run dev
1111
```
1212

1313
### Compiles and minifies for production
1414
```
1515
npm run build
1616
```
1717

18+
### Preview production build
19+
```
20+
npm run serve
21+
```
22+
1823
### Lints and fixes files
1924
```
2025
npm run lint

babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="/favicon.ico">
8+
<title>Hard Coded Url</title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13+
</noscript>
14+
<div id="app"></div>
15+
<script type="module" src="/src/main.js"></script>
16+
</body>
17+
</html>

package-lock.json

Lines changed: 4650 additions & 25220 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
{
2-
"name": "vue-2-migrate-cli-to-vite",
2+
"name": "vue-cli-to-vite-migration-example",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"serve": "vue-cli-service serve",
7-
"build": "vue-cli-service build",
8-
"lint": "vue-cli-service lint"
6+
"dev": "vite",
7+
"build": "vite build",
8+
"serve": "vite preview",
9+
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src"
910
},
1011
"dependencies": {
11-
"core-js": "^3.6.5",
1212
"vue": "^2.6.11",
1313
"vue-router": "^3.2.0",
1414
"vuex": "^3.4.0"
1515
},
1616
"devDependencies": {
17-
"@vue/cli-plugin-babel": "~4.5.0",
18-
"@vue/cli-plugin-eslint": "~4.5.0",
19-
"@vue/cli-plugin-router": "~4.5.0",
20-
"@vue/cli-plugin-vuex": "~4.5.0",
21-
"@vue/cli-service": "~4.5.0",
17+
"@vitejs/plugin-vue": "^1.6.1",
2218
"@vue/eslint-config-prettier": "^6.0.0",
23-
"babel-eslint": "^10.1.0",
24-
"eslint": "^6.7.2",
19+
"eslint": "^8.1.0",
2520
"eslint-plugin-prettier": "^3.3.1",
26-
"eslint-plugin-vue": "^6.2.2",
21+
"eslint-plugin-vue": "^8.0.1",
2722
"prettier": "^2.2.1",
2823
"sass": "^1.26.5",
29-
"sass-loader": "^8.0.2",
30-
"vue-template-compiler": "^2.6.11"
24+
"vite": "^2.5.4",
25+
"vite-plugin-vue2": "^1.9.0"
3126
}
3227
}

public/index.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/router/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ const routes = [
1616
// route level code-splitting
1717
// this generates a separate chunk (about.[hash].js) for this route
1818
// which is lazy-loaded when the route is visited.
19-
component: () =>
20-
import(/* webpackChunkName: "about" */ "../views/About.vue"),
19+
component: () => import("../views/About.vue"),
2120
},
2221
];
2322

2423
const router = new VueRouter({
2524
mode: "history",
26-
base: process.env.BASE_URL,
25+
base: import.meta.env.BASE_URL,
2726
routes,
2827
});
2928

vite.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from "vite";
2+
// import vue from '@vitejs/plugin-vue' // vue 3
3+
import { createVuePlugin as vue } from "vite-plugin-vue2"; //vue 2
4+
const path = require("path");
5+
6+
// https://vitejs.dev/config/
7+
export default defineConfig({
8+
plugins: [vue()],
9+
resolve: {
10+
alias: {
11+
"@": path.resolve(__dirname, "./src"),
12+
},
13+
},
14+
});

0 commit comments

Comments
 (0)