vite-plugin-yalc
v0.1.3
Published
A yalc plugin for vite-based library projects.
Maintainers
Readme
Overview
A yalc plugin for Vite-based library projects.
Prerequisites
- Node
- Yalc
Installation
npm i vite-plugin-yalc -DUsage
To push your build into the store, simply add the following:
// vite.config.ts
import path from 'path';
import { defineConfig } from 'vite';
import { runYalc } from 'vite-plugin-yalc';
export default defineConfig(({ mode }) => {
return {
base: './',
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'Project',
formats: ['es', 'cjs'],
fileName: format => `index.${format}.js`,
},
},
plugins: [runYalc()],
resolve: {
alias: {
src: path.resolve(__dirname, '/src'),
},
},
};
});
Or, to run a command and then push your build into the store do the following:
// vite.config.ts
import path from 'path';
import { defineConfig } from 'vite';
import { runCommand } from 'vite-plugin-yalc';
export default defineConfig(({ mode }) => {
return {
base: './',
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'Yalc',
formats: ['es', 'cjs'],
fileName: format => `index.${format}.js`,
},
},
plugins: [runCommand('npm run build:ts')],
resolve: {
alias: {
src: path.resolve(__dirname, '/src'),
},
},
};
});
Development
This project uses yalc for local development.
- npm run dev
- switch to project
- npx yalc add vite-plugin-yalc
- After that, this library will hot reload into the consuming application
Scripts
- We've included a couple of helpful scripts for faster development.
- deploy:
npm run deploy -- 'commit message' - publish:
npm run publish -- 'commit message' [major|minor|patch]
Husky
- Husky configuration is setup to lint and format the repo on every commit
- Edit the
.husky/pre-commitfile to change your settings
