Skip to content

Commit

Permalink
feat: update sdk to build as vite lib
Browse files Browse the repository at this point in the history
  • Loading branch information
SomethingSexy committed Jun 15, 2024
1 parent e76781e commit d7bcb18
Show file tree
Hide file tree
Showing 3 changed files with 230 additions and 7 deletions.
187 changes: 183 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 22 additions & 3 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,27 @@
"description": "",
"license": "MIT",
"author": "Tyler J Cvetan",
"sideEffects": [
"**/*.css"
],
"type": "module",
"main": "dist/index.js",
"exports": {
".": {
"import": {
"default": "./dist/@somethingsexy/sdk.es.js"
},
"require": {
"default": "./dist/@somethingsexy/sdk.umd.js"
}
},
"./styles.css": "./dist/index.css"
},
"main": "./dist/@somethingsexy/sdk.umd.js",
"module": "./dist/@somethingsexy/sdk.es.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "swc ./src -d dist --strip-leading-paths",
"build": "vite build",
"build:old": "swc ./src -d dist --strip-leading-paths",
"build:watch": "swc ./src -d dist -w --strip-leading-paths",
"lint": "eslint ./src --report-unused-disable-directives --max-warnings 0 --no-warn-ignored",
"lint:fix": "eslint ./src --report-unused-disable-directives --max-warnings 0 --no-warn-ignored --fix",
Expand All @@ -32,7 +48,10 @@
"devDependencies": {
"@swc/cli": "^0.3.12",
"@swc/core": "^1.5.28",
"@vitejs/plugin-react-swc": "^3.7.0",
"prettier": "3.3.2",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vite": "^5.3.1",
"vite-plugin-lib-inject-css": "^2.1.1"
}
}
25 changes: 25 additions & 0 deletions packages/sdk/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig } from 'vite'
import { libInjectCss } from 'vite-plugin-lib-inject-css'
import path from 'path'
import react from '@vitejs/plugin-react-swc'

export default defineConfig({
plugins: [react(), libInjectCss()],
build: {
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: '@somethingsexy/sdk',
fileName: (format) => `@somethingsexy/sdk.${format}.js`,
},
rollupOptions: {
external: ['react', 'react/jsx-runtime', 'react-dom'],
output: {
globals: {
react: 'react',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'react/jsx-runtime',
},
},
},
},
})

0 comments on commit d7bcb18

Please sign in to comment.