Skip to content

Commit 4f8d122

Browse files
committed
chore: optimize @mdi/js and sass
1 parent 1c3efa9 commit 4f8d122

File tree

5 files changed

+378
-50
lines changed

5 files changed

+378
-50
lines changed

packages/docs/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@vuetify/api-generator": "workspace:*",
5656
"ajv": "^8.12.0",
5757
"async-es": "^3.2.5",
58+
"mdi-js-es": "7.4.47",
5859
"date-fns": "^3.6.0",
5960
"emailjs-com": "^3.2.0",
6061
"front-matter": "^4.0.2",
@@ -74,7 +75,7 @@
7475
"unplugin-auto-import": "0.17.5",
7576
"unplugin-fonts": "1.0.3",
7677
"unplugin-vue-components": "^0.26.0",
77-
"vite": "^5.2.8",
78+
"vite": "5.4.0-beta.1",
7879
"vite-plugin-md": "^0.21.5",
7980
"vite-plugin-pages": "^0.32.1",
8081
"vite-plugin-pwa": "^0.17.4",

packages/docs/src/components/doc/IconList.vue

+19-8
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,32 @@
4646
</template>
4747

4848
<script setup>
49-
// Data
50-
import * as paths from '@mdi/js'
51-
5249
const { t } = useI18n()
5350
5451
const copied = shallowRef(false)
5552
const loading = shallowRef(true)
5653
const icons = shallowRef([])
54+
const paths = shallowRef({})
5755
const selection = shallowRef()
5856
const search = shallowRef('')
5957
60-
import('virtual:mdi-js-icons')
61-
.then(i => icons.value = i.icons)
62-
.catch(console.error)
63-
.finally(() => loading.value = false)
58+
const data = Promise.all([
59+
import('virtual:mdi-js-icons'),
60+
import('@mdi/js'),
61+
])
62+
63+
function load () {
64+
nextTick(() => {
65+
data.then(([i, p]) => {
66+
paths.value = p
67+
icons.value = i.icons
68+
})
69+
.catch(console.error)
70+
.finally(() => loading.value = false)
71+
})
72+
}
73+
74+
onMounted(load)
6475
6576
/** @param s {string} */
6677
function * mapIcons (s) {
@@ -96,7 +107,7 @@
96107
})
97108
98109
function getIcon (name) {
99-
return 'svg:' + paths[camelize('mdi-' + name)]
110+
return 'svg:' + paths.value[camelize('mdi-' + name)]
100111
}
101112
function itemProps (item) {
102113
return {

packages/docs/src/plugins/icons.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ export {
395395
mdiWindowMinimize,
396396
mdiWindowRestore,
397397
mdiWrench,
398-
} from '@mdi/js'
398+
} from 'mdi-js-es'
399399

400400
export const mdiDiscord = 'M22,24L16.75,19L17.38,21H4.5A2.5,2.5 0 0,1 2,18.5V3.5A2.5,2.5 0 0,1 4.5,1H19.5A2.5,2.5 0 0,1 22,3.5V24M12,6.8C9.32,6.8 7.44,7.95 7.44,7.95C8.47,7.03 10.27,6.5 10.27,6.5L10.1,6.33C8.41,6.36 6.88,7.53 6.88,7.53C5.16,11.12 5.27,14.22 5.27,14.22C6.67,16.03 8.75,15.9 8.75,15.9L9.46,15C8.21,14.73 7.42,13.62 7.42,13.62C7.42,13.62 9.3,14.9 12,14.9C14.7,14.9 16.58,13.62 16.58,13.62C16.58,13.62 15.79,14.73 14.54,15L15.25,15.9C15.25,15.9 17.33,16.03 18.73,14.22C18.73,14.22 18.84,11.12 17.12,7.53C17.12,7.53 15.59,6.36 13.9,6.33L13.73,6.5C13.73,6.5 15.53,7.03 16.56,7.95C16.56,7.95 14.68,6.8 12,6.8M9.93,10.59C10.58,10.59 11.11,11.16 11.1,11.86C11.1,12.55 10.58,13.13 9.93,13.13C9.29,13.13 8.77,12.55 8.77,11.86C8.77,11.16 9.28,10.59 9.93,10.59M14.1,10.59C14.75,10.59 15.27,11.16 15.27,11.86C15.27,12.55 14.75,13.13 14.1,13.13C13.46,13.13 12.94,12.55 12.94,11.86C12.94,11.16 13.45,10.59 14.1,10.59Z'
401401
export const mdiFormatTextdirectionLToR = 'M21,18L17,14V17H5V19H17V22M9,10V15H11V4H13V15H15V4H17V2H9A4,4 0 0,0 5,6A4,4 0 0,0 9,10Z'

packages/docs/vite.config.mts

+8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export default defineConfig(({ command, mode, isSsrBuild }) => {
5050
'process.env.NODE_ENV': mode === 'production' || isSsrBuild ? '"production"' : '"development"',
5151
__INTLIFY_PROD_DEVTOOLS__: 'false',
5252
},
53+
css: {
54+
preprocessorOptions: {
55+
sass: {
56+
api: 'modern'
57+
}
58+
},
59+
preprocessorMaxWorkers: true,
60+
},
5361
build: {
5462
sourcemap: mode === 'development',
5563
modulePreload: false,

0 commit comments

Comments
 (0)