Skip to content

Commit

Permalink
tentative fix
Browse files Browse the repository at this point in the history
  • Loading branch information
e-krebs committed Sep 22, 2024
1 parent d92ebe2 commit 908a62c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 44 deletions.
62 changes: 18 additions & 44 deletions .ladle/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,28 @@
import react from '@vitejs/plugin-react';
import fs from 'fs';
import { resolve } from 'path';
import tailwindcss from 'tailwindcss';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';

function inlineSvg(...paths) {
return {
name: 'inline-svg',
transformIndexHtml: {
enforce: 'pre',
transform: (html) => {
if (!Array.isArray(paths) || paths.length <= 0) return html;

let newHtml = html;
paths.forEach((svg) => {
const extractedSvg = fs.readFileSync(svg, 'utf8');
newHtml = newHtml.replace('<body>', `<body>${extractedSvg}`);
});
return newHtml;
},
export default defineConfig({
server: { open: false },
plugins: [react(), dts({ rollupTypes: true })],
css: {
postcss: {
plugins: [tailwindcss],
},
};
}

export default defineConfig(({ isSsrBuild, isPreview }) => {
const isLadle = isSsrBuild === undefined && isPreview === undefined;

return {
server: { open: false },
plugins: isLadle
? [inlineSvg('src/assets/icons.svg', '.ladle/assets/stories-icons.svg')]
: [react(), dts({ rollupTypes: true })],
css: {
postcss: {
plugins: [tailwindcss],
},
},
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: '@e-krebs/react-library',
fileName: 'index',
},
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
name: '@e-krebs/react-library',
fileName: 'index',
},
rollupOptions: {
external: ['react', 'react-dom', 'tailwindcss'],
output: { globals: { react: 'React', 'react-dom': 'ReactDOM', tailwindcss: 'tailwindcss' } },
},
sourcemap: true,
emptyOutDir: true,
rollupOptions: {
external: ['react', 'react-dom', 'tailwindcss'],
output: { globals: { react: 'React', 'react-dom': 'ReactDOM', tailwindcss: 'tailwindcss' } },
},
};
sourcemap: true,
emptyOutDir: true,
},
});
6 changes: 6 additions & 0 deletions pocstcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
}
}

0 comments on commit 908a62c

Please sign in to comment.