Skip to content

Commit

Permalink
Vite config adjustments (#88)
Browse files Browse the repository at this point in the history
Co-authored-by: tblackwell-tm <t.blackwell@techmodal.com>
  • Loading branch information
t-blackwell and tblackwell-tm authored Feb 19, 2025
1 parent 7cae2e4 commit 805557b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 29 deletions.
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Tom Blackwell",
"private": false,
"license": "MIT",
"version": "2.0.0",
"version": "2.0.1",
"description": "React crossword component",
"keywords": [
"react",
Expand All @@ -14,16 +14,21 @@
"main": "dist/main.js",
"module": "dist/main.js",
"types": "dist/main.d.ts",
"exports": {
".": {
"import": "./dist/main.js",
"types": "./dist/main.d.ts"
},
"./dist/*.css": "./dist/*.css"
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "https://github.com/t-blackwell/mycrossword"
},
"sideEffects": [
"**/*.css"
],
"sideEffects": true,
"scripts": {
"dev": "vite --open",
"build": "tsc --p ./tsconfig-build.json && vite build",
Expand Down
32 changes: 7 additions & 25 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { defineConfig } from 'vite';
import { extname, relative, resolve } from 'path';
import { fileURLToPath } from 'node:url';
import { glob } from 'glob';
import { resolve } from 'path';
import react from '@vitejs/plugin-react';
import dts from 'vite-plugin-dts';
import { libInjectCss } from 'vite-plugin-lib-inject-css';
Expand All @@ -20,31 +18,15 @@ export default defineConfig({
lib: {
entry: resolve(__dirname, 'lib/main.ts'),
formats: ['es'],
fileName: 'main',
},
rollupOptions: {
external: ['react', 'react/jsx-runtime'],
input: Object.fromEntries(
// https://rollupjs.org/configuration-options/#input
glob
.sync('lib/**/*.{ts,tsx}', {
ignore: [
'lib/**/*.d.ts',
'lib/**/*.test.{ts,tsx}',
'lib/testData/**',
],
})
.map((file) => [
// 1. The name of the entry point
// lib/nested/foo.js becomes nested/foo
relative('lib', file.slice(0, file.length - extname(file).length)),
// 2. The absolute path to the entry file
// lib/nested/foo.ts becomes /project/lib/nested/foo.ts
fileURLToPath(new URL(file, import.meta.url)),
]),
),
external: ['react', 'react/jsx-runtime', 'react-dom'],
output: {
assetFileNames: 'assets/[name][extname]',
entryFileNames: '[name].js',
// Force CSS code-splitting off
manualChunks: undefined,
// Ensure CSS is properly processed when code-split
inlineDynamicImports: true,
},
},
},
Expand Down

0 comments on commit 805557b

Please sign in to comment.