refactor: refactor with vite

This commit is contained in:
misitebao 2021-11-03 01:53:20 +08:00
parent abb9bf13fe
commit bac4ffe152
15 changed files with 348 additions and 22568 deletions

View File

@ -1,3 +0,0 @@
> 1%
last 2 versions
not dead

26
frontend/.gitignore vendored
View File

@ -1,23 +1,5 @@
.DS_Store
node_modules
# /dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.DS_Store
# dist
dist-ssr
*.local

3
frontend/.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["johnsoncodehk.volar"]
}

View File

@ -1,25 +0,0 @@
# wails-template-vue
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run dev
```
### Compiles and minifies for production
```
npm run build
```
### Open the web server to preview the packaged resources
```
npm run serve
```

13
frontend/index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,20 @@
{
"name": "{{.ProjectName}}",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",
"build": "vue-cli-service build",
"serve": "serve dist"
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"author": "{{.AuthorName}}",
"dependencies": {
"vue": "^3.0.0",
"vue-i18n": "^9.1.7",
"vue-router": "^4.0.0-0"
"vue": "^3.2.16",
"vue-i18n": "^9.1.9",
"vue-router": "^4.0.12"
},
"devDependencies": {
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"serve": "^12.0.0"
}
"@vitejs/plugin-vue": "^1.9.3",
"sass": "^1.43.4",
"vite": "^2.6.4"
},
"author": "{{.AuthorName}}"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
</body>
</html>

View File

@ -1,12 +1,16 @@
import { createI18n } from 'vue-i18n'
import zhHans from './messages/zh-Hans.json'
import en from './messages/en.json'
import fr from './messages/fr.json'
const i18n = createI18n({
locale: "en",
fallbackLocale: 'en',
messages: {
"zh-Hans": require('./messages/zh-Hans.json'),
"en": require('./messages/en.json'),
"fr": require('./messages/fr.json')
"zh-Hans": zhHans,
"en": en,
"fr": fr
}
})

View File

@ -1,7 +1,7 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import i18n from './i18n'
import router from '@/router'
import i18n from '@/i18n'
// Register global common components
// 注册全局通用组件

View File

@ -1,5 +1,5 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'
import Home from '@/views/Home.vue'
const routes = [
{

22
frontend/vite.config.js Normal file
View File

@ -0,0 +1,22 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
},
},
build: {
rollupOptions: {
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`,
}
},
}
})

View File

@ -1,10 +0,0 @@
module.exports = {
// The build file does not use the hash file name
// 构建文件不使用hash文件名
filenameHashing: false,
// Package the css into a separate file
// 将css打包到单独的文件
css: {
extract: "true"
}
}

View File

@ -3,7 +3,6 @@
"outputfilename": "{{.BinaryName}}",
"assetdir": "frontend/dist",
"frontend:install": "npm install",
"frontend:dev":"",
"frontend:build": "npm run build",
"author": {
"name": "{{.AuthorName}}",