Skip to content

altipla-consulting/vite-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vite-config

Configure vite with sane defaults for our projects.

Install

npm i @altipla/vite-config

Usage

Applications

Use the exported function from this package to configure the vite.config.js file in your project:

import { extendConfig } from '@altipla/vite-config'


export default extendConfig()

Library mode

To build libraries configure the special mode:

import { extendLibConfig } from '@altipla/vite-config'


export default extendLibConfig()

The default configuration builds a ES module. If you want to customize the outputs to emit the IIFE format for example extend the configuration with a name too:

import { extendLibConfig } from '@altipla/vite-config'


export default extendLibConfig({
  build: {
    lib: {
      name: 'example',
      formats: ['es', 'iife'],
    },
  },
})

Use this library mode with a new npm run lib command in the package.json scripts section:

{
  "scripts": {
    "start": "vite",
    "build": "echo VITE_VERSION=$BUILD_ID > .env.production && NODE_ENV=production vite build && rm .env.production",
    "lib": "echo VITE_VERSION=$BUILD_ID > .env.lib && NODE_ENV=production vite build --mode lib && rm .env.lib"
  }
}