-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
}, | ||
}, | ||
}); |