Skip to content

Commit

Permalink
chore: update build system
Browse files Browse the repository at this point in the history
  • Loading branch information
h2xd committed Jul 4, 2024
1 parent b916336 commit bb9ce39
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 92 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"module": "./dist/index.es.js"
},
"engines": {
"node": "18",
"pnpm": "8"
"node": ">=18",
"pnpm": ">=8"
},
"files": [
"dist"
Expand All @@ -23,7 +23,7 @@
"build:scripts": "vite build",
"build:types": "tsc --emitDeclarationOnly && tsc-alias",
"build:styles": "NODE_ENV=production pnpm tailwindcss -i ./src/styles/globals.css -o ./dist/styles.css --postcss --minify",
"publish:ci": "pnpm publish --no-git-checks --dry-run",
"publish:ci": "pnpm publish --no-git-checks",
"publish:dry": "pnpm publish --no-git-checks --dry-run",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint . --fix --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
Expand Down
25 changes: 0 additions & 25 deletions src/index.ts

This file was deleted.

115 changes: 51 additions & 64 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,62 @@
import { resolve } from 'path'
import { resolve } from "path";

import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";

import packageData from './package.json'
import packageData from "./package.json";

type BuildEnvironment = 'storybook' | 'library'
type BuildEnvironment = "storybook" | "library";

const buildEnvironment: BuildEnvironment = (process.env.BUILD_ENV as BuildEnvironment) || 'library'
const buildEnvironment: BuildEnvironment =
(process.env.BUILD_ENV as BuildEnvironment) || "library";

const libPlugins = [
react({
jsxRuntime: 'classic'
}),
dts({
rollupTypes: true
}),
viteStaticCopy({
targets: [
{
src: './src/export/styles.css',
dest: '.'
},
{
src: './src/export/fonts',
dest: '.'
},
{
src: './src/export/tailwind.config.js',
dest: '.'
}
]
})
]
react({
jsxRuntime: "classic",
}),
dts({
rollupTypes: true,
}),
];

const storybookPlugins = [
react({
jsxRuntime: 'automatic'
})
]
react({
jsxRuntime: "automatic",
}),
];

// https://vitejs.dev/config/
export default defineConfig({
plugins: buildEnvironment === 'storybook' ? storybookPlugins : libPlugins,
build: {
lib: {
entry: resolve(__dirname, 'src', 'index.ts'),
formats: ['es', 'cjs'],
fileName: (format) => `index.${format}.js`
},
rollupOptions: {
external:
buildEnvironment === 'storybook'
? []
: [...Object.keys(packageData.peerDependencies), ...Object.keys(packageData?.dependencies || [])],
output: {
// Since we publish our ./src folder, there's no point
// in bloating sourcemaps with another copy of it.
sourcemapExcludeSources: true
}
},
target: 'esnext',
sourcemap: true,
minify: false
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@hivemq/ui-shell': resolve(__dirname, './src/lib.ts')
}
}
})
plugins: buildEnvironment === "storybook" ? storybookPlugins : libPlugins,
build: {
lib: {
entry: resolve(__dirname, "src", "lib.ts"),
formats: ["es", "cjs"],
fileName: (format) => `index.${format}.js`,
},
rollupOptions: {
external:
buildEnvironment === "storybook"
? []
: [
...Object.keys(packageData.peerDependencies),
...Object.keys(packageData.devDependencies),
],
output: {
// Since we publish our ./src folder, there's no point
// in bloating sourcemaps with another copy of it.
sourcemapExcludeSources: true,
},
},
target: "esnext",
sourcemap: true,
minify: false,
},
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
"@hivemq/ui-shell": resolve(__dirname, "./src/lib.ts"),
},
},
});

0 comments on commit bb9ce39

Please sign in to comment.