feat: add lib alias in vite config and tsconfig

The commit includes a new alias @pswui-lib in both the `vite.config.ts` and `tsconfig.json` files. This change facilitates a more straightforward and concise import of files located in the 'lib' directory.
This commit is contained in:
p-sw 2024-06-11 15:43:56 +09:00
parent fcc35223d3
commit edfaef2c75
2 changed files with 20 additions and 11 deletions

View File

@ -24,9 +24,10 @@
"baseUrl": "./", "baseUrl": "./",
"paths": { "paths": {
"@components/*": ["components/*"], "@components/*": ["components/*"],
"@/*": ["src/*"] "@/*": ["src/*"],
"@pswui-lib/*": ["lib/*"]
} }
}, },
"include": ["components", "src"], "include": ["components", "src", "lib"],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }]
} }

View File

@ -1,17 +1,24 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import tailwindcss from "tailwindcss"; import tailwindcss from "tailwindcss";
import mdx from '@mdx-js/rollup'; import mdx from "@mdx-js/rollup";
import { resolve } from 'node:path'; import { resolve } from "node:path";
import remarkGfm from "remark-gfm"; import remarkGfm from "remark-gfm";
import withSlug from "rehype-slug" import withSlug from "rehype-slug";
import withToc from "@stefanprobst/rehype-extract-toc"; import withToc from "@stefanprobst/rehype-extract-toc";
import withTocExport from "@stefanprobst/rehype-extract-toc/mdx"; import withTocExport from "@stefanprobst/rehype-extract-toc/mdx";
import dynamicImport from 'vite-plugin-dynamic-import' import dynamicImport from "vite-plugin-dynamic-import";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react(), mdx({ rehypePlugins: [withSlug, withToc, withTocExport], remarkPlugins: [remarkGfm] }), dynamicImport()], plugins: [
react(),
mdx({
rehypePlugins: [withSlug, withToc, withTocExport],
remarkPlugins: [remarkGfm],
}),
dynamicImport(),
],
css: { css: {
postcss: { postcss: {
plugins: [tailwindcss()], plugins: [tailwindcss()],
@ -19,8 +26,9 @@ export default defineConfig({
}, },
resolve: { resolve: {
alias: { alias: {
'@components': resolve(__dirname, './components'), "@components": resolve(__dirname, "./components"),
'@': resolve(__dirname, './src'), "@": resolve(__dirname, "./src"),
} "@pswui-lib": resolve(__dirname, "./lib"),
} },
},
}); });