Skip to content

Commit 65cb12b

Browse files
committed
refactor: preformance changes
1 parent 798c078 commit 65cb12b

File tree

8 files changed

+513
-31
lines changed

8 files changed

+513
-31
lines changed

index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
<head>
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/favicon.ico" />
6+
7+
<link
8+
rel="preload"
9+
href="https://unpkg.com/[email protected]/styles/ascetic.css"
10+
as="style"
11+
onload="this.onload=null;this.rel='stylesheet'"
12+
/>
13+
<noscript
14+
><link
15+
rel="stylesheet"
16+
href="https://unpkg.com/[email protected]/styles/ascetic.css"
17+
/></noscript>
618
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
719
<title>Mark</title>
820

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
"codejar": "^3.5.0",
1212
"highlight.js": "^11.2.0",
1313
"marked": "^3.0.2",
14-
"tailwindcss": "^2.2.7",
1514
"vue": "^3.0.5"
1615
},
1716
"devDependencies": {
17+
"tailwindcss": "^2.2.7",
1818
"@vitejs/plugin-vue": "^1.3.0",
1919
"@vue/compiler-sfc": "^3.0.5",
2020
"autoprefixer": "^10.3.2",
21+
"cssnano": "^5.0.8",
2122
"postcss": "^8.3.6",
2223
"vite": "^2.4.4"
2324
}

postcss.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
plugins: {
33
tailwindcss: {},
4-
autoprefixer: {}
5-
}
6-
}
4+
autoprefixer: {},
5+
cssnano: {},
6+
},
7+
};

src/components/editor.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@
99
</div>
1010
</template>
1111
<script>
12-
import { reactive, ref, onMounted, watchEffect } from "vue";
12+
import { ref, onMounted } from "vue";
1313
import { CodeJar } from "codejar";
14-
import hljs from "highlight.js";
14+
import hljs from "highlight.js/lib/core";
15+
import javascript from "highlight.js/lib/languages/javascript";
16+
import markdown from "highlight.js/lib/languages/markdown";
17+
import golang from "highlight.js/lib/languages/go";
18+
19+
hljs.registerLanguage("javascript", javascript);
20+
hljs.registerLanguage("markdown", markdown);
21+
hljs.registerLanguage("go", golang);
1522
1623
const props = {
1724
code: String,

src/main.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
import { createApp, h } from 'vue'
2-
import Home from './pages/Home.vue'
3-
import './styles/index.css'
1+
import { createApp, h } from "vue";
2+
import Home from "./pages/Home.vue";
3+
import "./styles/index.css";
4+
import "./styles/fonts.css";
45

56
const routes = {
6-
'/': Home
7+
"/": Home,
78
// TODO: add a settings page
89
// "/settings": Home,
9-
}
10+
};
1011

1112
const SimpleRouter = {
1213
data: () => ({
13-
currentRoute: window.location.pathname
14+
currentRoute: window.location.pathname,
1415
}),
1516

1617
computed: {
17-
CurrentComponent () {
18-
return routes[this.currentRoute]
19-
}
18+
CurrentComponent() {
19+
return routes[this.currentRoute];
20+
},
2021
},
2122

22-
render () {
23-
return h(this.CurrentComponent)
24-
}
25-
}
23+
render() {
24+
return h(this.CurrentComponent);
25+
},
26+
};
2627

27-
createApp(SimpleRouter).mount('#app')
28+
createApp(SimpleRouter).mount("#app");

src/styles/index.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
@import url("https://unpkg.com/[email protected]/styles/ascetic.css");
2-
@import "./fonts.css";
3-
41
:root {
52
--grid-point: 4px;
63
}

vite.config.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
import { defineConfig } from 'vite'
2-
import vue from '@vitejs/plugin-vue'
1+
import { defineConfig } from "vite";
2+
import vue from "@vitejs/plugin-vue";
33

44
// https://vitejs.dev/config/
55
export default defineConfig({
6-
plugins: [vue()]
7-
})
6+
plugins: [vue()],
7+
build: {
8+
rollupOptions: {
9+
output: {
10+
manualChunks: {
11+
highlightjs: ["highlight.js"],
12+
},
13+
},
14+
},
15+
terserOptions: {
16+
compress: {
17+
passes: 10,
18+
},
19+
},
20+
},
21+
});

0 commit comments

Comments
 (0)