Add aliasing support to Vite from tsconfig.json or jsconfig.json files

Overview

Config to Alias Config to Alias

NPM Version Licensing

Config to Alias adds aliasing support to Astro, JavaScript, TypeScript, and CSS files.

Usage

Install Config to Alias.

npm install @astropub/config-to-alias

Add Config to Alias to your astro.config.js.

import { defineConfig } from 'astro/config'
import configToAlias from '@astropub/config-to-alias/astro'

export default defineConfig({
  integrations: [
    configToAlias()
  ]
})

That’s it!

Now, any aliases added to tsconfig.json or jsconfig.json ...

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "src:*": ["src/*"]
    }
  }
}

... can be used in JavaScript, TypeScript, and Astro files ...

import * as utils from 'src:scripts/utils.astro'

... and CSS files, too!

@import 'src:styles/shared.css'

Usage with Vite

Add Config to Alias to your vite.config.js.

import { defineConfig } from 'vite'
import configToAlias from '@astropub/config-to-alias/vite'

export default defineConfig({
  plugins: [
    configToAlias()
  ]
})

Author’s Note

This integration exists as a standalone version of the vite-plugin-config-alias plugin built into Astro with additional support for CSS. At the time of writing, Astro has not added this functionality to core because my contributions are currently banned from being used in the project. As they do not yet have any process to appeal a ban, this plugin serves as a crutch.

You might also like...

🌸 A cli can automatically generate files from Excel files.

🌸 A cli can automatically generate files from Excel files.

unxlsx A cli can automatically generate files from Excel files. Why We often need to export some information from XLSX to generate our files, such as

Aug 22, 2022

JavaScript library for parsing Dirtywave M8 files, complete with a CLI for interacting with M8 files.

m8-js This repository contains a JavaScript library for parsing Dirtywave M8 files, as well as a CLI for interacting with M8 files. The hopes are not

Dec 17, 2022

Download all Moodle files with one click. This is a Chrome extension built to save time and effort from downloading files manually one by one!

Download all Moodle files with one click. This is a Chrome extension built to save time and effort from downloading files manually one by one!

Moodle Downloader Extension Moodle downloader extension for Chrome. The extension is tested with both the TUM moodle and the official moodle demo. Not

Nov 15, 2022

Vaultacks lets users store files off-chain on Gaia. Files are encrypted by default but also can be made public and shared

Vaultacks lets users store files off-chain on Gaia. Files are encrypted by default but also can be made public and shared

Vaultacks Vaultacks is built on the Stacks Chain. It lets users upload files to Gaia, a off-chain data storage system. Vaultacks currently uses the de

Sep 14, 2022

Obsidian plugin that allows user to create a glossary of files, an index of files or both.

Obsidian Auto Glossary Auto Glossary is an Obsidian plugin to create a glossary, an index or a glossary with an index from the files you want. Feature

Dec 30, 2022

A website for tracking community support for BIP21 QR codes that support on-chain and lightning bitcoin payments.

BIP21 Microsite This is a WIP microsite to promote the usage of a BIP21 payment URI QR code that can include lightning invoices or offers. Wallet supp

Nov 27, 2022

Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all with IndexedDB. Perfectly suitable for your next (PWA) app.

Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all with IndexedDB. Perfectly suitable for your next (PWA) app.

BrowstorJS 🚀 💾 🔒 Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all

Aug 5, 2022

This extension allows you to create Markdown files which are automatically transformed to in-game documentation for your Add-On.

This extension allows you to create Markdown files which are automatically transformed to in-game documentation for your Add-On.

Markdown Doc Generator An extension for bridge editor which makes creating docs in minecraft easier, by generating json-ui from markdown View extensio

Dec 31, 2022

Plug-in for Obsidian.md which will create Notes from JSON files

Import JSON This plug-in provides you with the tools to import your favourite JSON tables. A magnifying-glass icon will appear in the left margin when

Dec 31, 2022
Owner
Astro Community
Community maintained repos from the Astro ecosystem.
Astro Community
Find and parse the tsconfig.json file from a directory path

get-tsconfig Find and parse tsconfig.json files. Features Zero dependencies (not even TypeScript) Tested against TypeScript for accuracy Supports comm

hiroki osame 66 Jan 2, 2023
Vite plugin to client bundle i18next locales composited from one to many json/yaml files from one to many libraries. Zero config HMR support included.

vite-plugin-i18next-loader yarn add -D vite-plugin-i18next-loader Vite plugin to client bundle i18next locales composited from one to many json/yaml f

AlienFast 4 Nov 30, 2022
mini vite, support static server, load ts files, pre-bundling.

Mini Vite 中文 Features Same structure with Vite. Support JS, TS, JSX, TSX, CSS, static files. Support public as public directory. Dependency Pre-Bundli

mysteryven 4 Sep 15, 2022
Out-of-the-box MPA plugin for Vite, with html template engine and virtual files support.

vite-plugin-virtual-mpa Out-of-the-box MPA plugin for Vite, with html template engine and virtual files support, generate multiple files using only on

QinXuYang 21 Dec 16, 2022
Query for CSS brower support data, combined from caniuse and MDN, including version support started and global support percentages.

css-browser-support Query for CSS browser support data, combined from caniuse and MDN, including version support started and global support percentage

Stephanie Eckles 65 Nov 2, 2022
Piplup: decompile Playdate Pulp .pdx files back to .json project files

Piplup: decompile Playdate Pulp .pdx files back to .json project files This doesn't work yet: I still need to: convert the graphics (.pdt files) back

null 6 Mar 25, 2022
A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YAML support designed to be easy to set up and use

About A high-resolution local database that uses precise algorithms to easily record data in local files within a project with persistent JSON and YML

Shuruhatik 5 Dec 28, 2022
Detect webpage updates and notify user to reload. support vite and umijs

English | 简体中文 plugin-web-update-notification Detect webpage updates and notify user to reload. support vite and umijs. Take the git commit hash as th

Utopia 57 Dec 26, 2022
JCS (JSON Canonicalization Scheme), JSON digests, and JSON Merkle hashes

JSON Hash This package contains the following JSON utilties for Deno: digest.ts provides cryptographic hash digests of JSON trees. It guarantee that d

Hong Minhee (洪 民憙) 13 Sep 2, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 2022