From 0e7e3bbc9c2abc8faea4a0cd21c871b7eb11427c Mon Sep 17 00:00:00 2001 From: Nuckle Date: Wed, 25 Sep 2024 14:14:24 +0300 Subject: [PATCH] Update vite js path resolver --- src/sass/base/config.scss | 4 ++-- vite.config.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/sass/base/config.scss b/src/sass/base/config.scss index 8c29373..3196c8b 100644 --- a/src/sass/base/config.scss +++ b/src/sass/base/config.scss @@ -16,10 +16,10 @@ $gutter: $grid-gutter-width; @use 'sass:meta'; :root[color-mode='light'] { - @include meta.load-css('../../../node_modules/highlight.js/styles/atom-one-light'); + @include meta.load-css('~highlight.js/styles/atom-one-light'); } :root[color-mode='dark'] { - @include meta.load-css('../../../node_modules/highlight.js/styles/atom-one-dark'); + @include meta.load-css('~highlight.js/styles/atom-one-dark'); } // FONTS LOAD SECTION diff --git a/vite.config.js b/vite.config.js index 865ac66..7ab101a 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,5 +1,5 @@ import { defineConfig } from 'vite'; -import { resolve, relative, extname } from 'path'; +import { resolve, relative, extname, join } from 'path'; import { fileURLToPath } from 'url'; import { VitePWA } from 'vite-plugin-pwa'; import glob from 'fast-glob'; @@ -21,6 +21,19 @@ export default defineConfig({ ], }, }, + resolve: { + alias: [ + { + find: /~(.+)/, + replacement: join(process.cwd(), 'node_modules/$1'), + }, + + { + find: /@\//, + replacement: join(process.cwd(), './src/renderer') + '/', + }, + ], + }, plugins: [ viteSvgSpriteWrapper({ icons: './src/img/svg/*.svg',