Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
fix: karbon cli config
Browse files Browse the repository at this point in the history
  • Loading branch information
SidStraw committed Nov 28, 2023
1 parent 5305199 commit 51045ee
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
46 changes: 27 additions & 19 deletions packages/karbon/src/cli/bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { once } from 'remeda'
import type { OutputChunk, OutputOptions } from 'rollup'
import type { BuildOptions } from 'vite'
import invariant from 'tiny-invariant'
import fs from 'fs-extra'
import importerChecker from '../plugins/importer-checker'
import { ignoreSet, targetSet } from './setting'

Expand Down Expand Up @@ -73,6 +74,8 @@ export async function bundle(path: string, vuefileName: string, layoutName: stri
const rollupOptions = createConfig(name, dir, ssr)
const config = await loadNuxtConfigOnce()

const tailwindConfigPath = `${process.cwd()}/tailwind.config.js`

await viteBuild({
clearScreen: false,
resolve: {
Expand All @@ -93,17 +96,22 @@ export async function bundle(path: string, vuefileName: string, layoutName: stri
postcss: {
plugins: [
tailwind({
config: {
content: [
`${process.cwd()}/templates/article-layouts/*.{vue,ts,tsx}`,
`${process.cwd()}/templates/editor-blocks/*.{vue,ts,tsx}`,
`${process.cwd()}/templates/components/**/*.{vue,ts,tsx}`,
],
corePlugins: {
preflight: false,
presets: [
{
config: {
content: [
`${process.cwd()}/templates/article-layouts/*.{vue,ts,tsx}`,
`${process.cwd()}/templates/editor-blocks/*.{vue,ts,tsx}`,
`${process.cwd()}/templates/components/**/*.{vue,ts,tsx}`,
],
corePlugins: {
preflight: false,
},
darkMode: ['class', '.force-use-dark-mode'],
},
},
darkMode: ['class', '.force-use-dark-mode'],
},
],
config: tailwindConfigPath,
}),
],
},
Expand All @@ -114,15 +122,15 @@ export async function bundle(path: string, vuefileName: string, layoutName: stri
: [
virtual({
entry: `
import component from './${join(path)}'
import './main.css'
export default component
`,
import component from './${join(path)}'
import './main.css'
export default component
`,
'main.css': `@tailwind base;
@tailwind components;
@tailwind utilities;
`,
@tailwind components;
@tailwind utilities;
`,
}),
]),
tsconfigPaths(),
Expand Down Expand Up @@ -150,7 +158,7 @@ export async function bundle(path: string, vuefileName: string, layoutName: stri
'vue',
{
'@storipress/custom-field': ['useField', 'FieldType'],
'@storipress/sdk/article/utils': ['useArticle', 'useRecommendArticle', 'useSite'],
'@storipress/sdk/article/utils': ['useArticle', 'useRecommendArticle', 'useSite', 'useColorMode'],
'@storipress/sdk/resources': ['useResourceResolver'],
},
],
Expand Down
10 changes: 9 additions & 1 deletion packages/karbon/src/cli/bundle/setting.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
export const ignoreSet = new Set(['NuxtLink', 'ClientOnly'])
export const targetSet = new Set(['ArticleTitle', 'ArticleHeroPhoto', 'ArticleBody', 'ArticleBlurb', 'Icon'])
export const targetSet = new Set([
'ArticleTitle',
'ArticleHeroPhoto',
'ArticleBody',
'ArticleBlurb',
'Icon',
'NuxtImg',
'NuxtPicture',
])
6 changes: 5 additions & 1 deletion packages/karbon/src/cli/karbon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ async function testBuild() {

if (packageManager === 'yarn') {
await configYarn(path.resolve(tempPath, './.yarnrc.yml'))
await $$`yarn set version berry`
// eslint-disable-next-line @typescript-eslint/no-require-imports
const packageJson = require(path.resolve(tempPath, './package.json'))
const version = packageJson?.packageManager?.split?.('@')?.[1] || 'berry'

await $$`yarn set version ${version}`
}
await $$`${packageManager} install`
const { exitCode, stderr } = await $$`npx nuxi build`
Expand Down

0 comments on commit 51045ee

Please sign in to comment.