🔧 (vite) migrate to vite (#7)

This commit is contained in:
Julien Calixte
2023-07-01 23:08:53 +02:00
committed by GitHub
parent 077c04b482
commit e4bba8246b
10 changed files with 370 additions and 5939 deletions

View File

@@ -1,7 +1,8 @@
module.exports = { module.exports = {
root: true, root: true,
env: { env: {
node: true node: true,
es2022: true
}, },
extends: [ extends: [
'plugin:vue/vue3-essential', 'plugin:vue/vue3-essential',
@@ -11,9 +12,6 @@ module.exports = {
'@vue/prettier/@typescript-eslint', '@vue/prettier/@typescript-eslint',
'plugin:prettier-vue/recommended' 'plugin:prettier-vue/recommended'
], ],
parserOptions: {
ecmaVersion: 2020
},
rules: { rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

View File

@@ -4,17 +4,17 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" /> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<title>Lite note</title> <title>Lite note</title>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong <strong
>We're sorry but Lite note doesn't work properly without JavaScript >We're sorry but this app doesn't work properly without JavaScript
enabled. Please enable it to continue.</strong enabled. Please enable it to continue.</strong
> >
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <script type="module" src="/src/main.ts"></script>
</body> </body>
</html> </html>

View File

@@ -3,20 +3,21 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "dev": "vite",
"build": "vue-cli-service build", "build": "vite build",
"serve": "vite preview",
"test": "vitest", "test": "vitest",
"lint": "vue-cli-service lint", "lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
"pwa:asset": "npx vue-pwa-asset-generator -a public/img/logo.png --no-manifest" "pwa:asset": "npx vue-pwa-asset-generator -a public/img/logo.png --no-manifest"
}, },
"dependencies": { "dependencies": {
"@octokit/core": "^3.5.1", "@octokit/core": "^4.2.4",
"@octokit/rest": "^18.12.0", "@octokit/rest": "^19.0.13",
"@toycode/markdown-it-class": "^1.2.4", "@toycode/markdown-it-class": "^1.2.4",
"@vueuse/core": "^7.2.2", "@vueuse/core": "^7.2.2",
"bulma": "^0.9.4", "bulma": "^0.9.4",
"core-js": "^3.31.0",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"isomorphic-fetch": "^3.0.0",
"markdown-it": "^12.3.0", "markdown-it": "^12.3.0",
"markdown-it-block-embed": "^0.0.3", "markdown-it-block-embed": "^0.0.3",
"markdown-it-checkbox": "^1.1.0", "markdown-it-checkbox": "^1.1.0",
@@ -30,8 +31,8 @@
"register-service-worker": "^1.7.2", "register-service-worker": "^1.7.2",
"retrobus": "^1.9.1", "retrobus": "^1.9.1",
"sanitize-html": "^2.11.0", "sanitize-html": "^2.11.0",
"vue": "^3.2.24", "vue": "^3.3.4",
"vue-i18n": "^9.0.0", "vue-i18n": "^9.2.2",
"vue-router": "^4.0.0-rc.2", "vue-router": "^4.0.0-rc.2",
"vuex": "^4.0.0-rc.1" "vuex": "^4.0.0-rc.1"
}, },
@@ -43,13 +44,7 @@
"@types/sanitize-html": "^2.6.0", "@types/sanitize-html": "^2.6.0",
"@typescript-eslint/eslint-plugin": "^5.6.0", "@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0", "@typescript-eslint/parser": "^5.6.0",
"@vue/cli-plugin-babel": "~5.0.8", "@vitejs/plugin-vue": "^4.2.3",
"@vue/cli-plugin-eslint": "~5.0.8",
"@vue/cli-plugin-pwa": "~5.0.8",
"@vue/cli-plugin-router": "~5.0.8",
"@vue/cli-plugin-typescript": "~5.0.8",
"@vue/cli-plugin-vuex": "~5.0.8",
"@vue/cli-service": "~5.0.8",
"@vue/compiler-sfc": "^3.2.24", "@vue/compiler-sfc": "^3.2.24",
"@vue/eslint-config-prettier": "^6.0.0", "@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^9.1.0", "@vue/eslint-config-typescript": "^9.1.0",
@@ -61,8 +56,9 @@
"eslint-plugin-vue": "^8.2.0", "eslint-plugin-vue": "^8.2.0",
"node-sass": "^9.0.0", "node-sass": "^9.0.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"sass-loader": "^13.3.2", "sass": "^1.63.6",
"typescript": "~4.5.3", "typescript": "~4.5.3",
"vite": "^4.3.9",
"vitest": "^0.32.2", "vitest": "^0.32.2",
"webpack": "^5.0.0" "webpack": "^5.0.0"
} }

6205
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,8 +3,8 @@
import { serviceWorkerBusEvent } from '@/bus/serviceWorkerEventBus' import { serviceWorkerBusEvent } from '@/bus/serviceWorkerEventBus'
import { register } from 'register-service-worker' import { register } from 'register-service-worker'
if (process.env.NODE_ENV === 'production') { if (import.meta.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, { register(`${import.meta.env.BASE_URL}service-worker.js`, {
ready() { ready() {
console.log( console.log(
'App is being served from cache by a service worker.\n' + 'App is being served from cache by a service worker.\n' +

View File

@@ -6,8 +6,7 @@ const routes: Array<RouteRecordRaw> = [
{ {
path: '/repo-list', path: '/repo-list',
name: 'RepoList', name: 'RepoList',
component: () => component: () => import('@/views/RepoList.vue')
import(/* webpackChunkName: "repo-list" */ '@/views/RepoList.vue')
}, },
{ {
path: '/:user?/:repo?', path: '/:user?/:repo?',
@@ -19,56 +18,45 @@ const routes: Array<RouteRecordRaw> = [
path: '/:user/:repo/share/:note', path: '/:user/:repo/share/:note',
name: 'ShareNotes', name: 'ShareNotes',
props: true, props: true,
component: () => component: () => import('@/views/ShareNotes.vue')
import(/* webpackChunkName: "share-notes" */ '@/views/ShareNotes.vue')
}, },
{ {
path: '/:user/:repo/inbox', path: '/:user/:repo/inbox',
name: 'FleetingNotes', name: 'FleetingNotes',
props: true, props: true,
component: () => component: () => import('@/views/FleetingNotes.vue')
import(/* webpackChunkName: "inbox" */ '@/views/FleetingNotes.vue')
}, },
{ {
path: '/:user/:repo/draft', path: '/:user/:repo/draft',
name: 'DraftNotes', name: 'DraftNotes',
props: true, props: true,
component: () => component: () => import('@/views/DraftNotes.vue')
import(/* webpackChunkName: "draft-notes" */ '@/views/DraftNotes.vue')
}, },
{ {
path: '/:user/:repo/history', path: '/:user/:repo/history',
name: 'HistoricNotes', name: 'HistoricNotes',
props: true, props: true,
component: () => component: () => import('@/views/HistoricNotes.vue')
import(
/* webpackChunkName: "historic-notes" */ '@/views/HistoricNotes.vue'
)
}, },
{ {
path: '/:user/:repo/spaced-repetition', path: '/:user/:repo/spaced-repetition',
name: 'SpacedRepetitionCard', name: 'SpacedRepetitionCard',
props: true, props: true,
component: () => component: () => import('@/views/SpacedRepetitionCard.vue')
import(
/* webpackChunkName: "spaced-repetition-card" */ '@/views/SpacedRepetitionCard.vue'
)
}, },
{ {
path: '/about', path: '/about',
name: 'About', name: 'About',
component: () => component: () => import('@/views/AboutApp.vue')
import(/* webpackChunkName: "about" */ '@/views/AboutApp.vue')
}, },
{ {
path: '/:catchAll(.*)', path: '/:catchAll(.*)',
name: 'SpaceCowboy', name: 'SpaceCowboy',
component: () => component: () => import('@/views/SpaceCowboy.vue')
import(/* webpackChunkName: "space-cowboy" */ '@/views/SpaceCowboy.vue')
} }
] ]
export const router = createRouter({ export const router = createRouter({
history: createWebHistory(process.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
routes routes
}) })

View File

@@ -26,7 +26,7 @@ $family-primary: 'Courier Prime', monospace;
--note-width: 620px; --note-width: 620px;
} }
@import '~bulma/bulma.sass'; @import '../../node_modules/bulma/bulma.sass';
html { html {
overflow-y: auto; overflow-y: auto;
@@ -41,6 +41,7 @@ body {
} }
@media screen and (min-width: 769px) { @media screen and (min-width: 769px) {
html, html,
body { body {
overflow-y: hidden; overflow-y: hidden;
@@ -91,6 +92,7 @@ a {
} }
@media print { @media print {
html, html,
body { body {
overflow-y: auto; overflow-y: auto;
@@ -110,4 +112,4 @@ pre {
code { code {
font-family: var(--font-family); font-family: var(--font-family);
} }

View File

@@ -12,7 +12,7 @@
"sourceMap": true, "sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"resolveJsonModule": true, "resolveJsonModule": true,
"types": ["node"], "types": ["node", "vite/client"],
"paths": { "paths": {
"@/*": ["src/*"] "@/*": ["src/*"]
}, },

13
vite.config.ts Normal file
View File

@@ -0,0 +1,13 @@
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'node-fetch': 'isomorphic-fetch'
}
}
})

View File

@@ -1,9 +0,0 @@
import path from 'path'
export default {
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
}
}