Skip to content

Commit

Permalink
feat: use vite 3
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Jul 15, 2022
1 parent 099cd4f commit 4371c05
Show file tree
Hide file tree
Showing 15 changed files with 310 additions and 778 deletions.
2 changes: 1 addition & 1 deletion .stacks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The ultimate goal of this framework, Stacks, is to _help you_ create a component

Other included core features are:

- ⚡️ Vite & unbuild plugins to build the component library
- ⚡️ Vite plugins to build the component library
- 🏎 Blazing fast, empowered by a beautiful DX
- 👣 Tiny foot-print in production builds
- 💬 Fully-typed TypeScript definitions
Expand Down
15 changes: 15 additions & 0 deletions .stacks/build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [
'src/index',
'src/cli',
],
declaration: true,
clean: true,
externals: ['vitepress', 'stacks'],
rollup: {
emitCJS: true,
inlineDependencies: true,
},
})
6 changes: 0 additions & 6 deletions .stacks/index.ts

This file was deleted.

15 changes: 9 additions & 6 deletions .stacks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"pnpm": ">=7.5.1"
},
"scripts": {
"artisan": "esno ./src/cli/run.ts",
"nitro:build": "nitro build",
"make:component": "wip",
"make:function": "wip",
Expand All @@ -69,17 +70,18 @@
"dev:elements": "unbuild ../components --stub",
"dev:pages": "nitro dev",
"dev:functions": "unbuild ../functions --stub",
"dev:stacks": "unbuild --stub",
"dev:stacks": "unbuild ./src --stub",
"dev:playground": "vite serve ../apps/playground -c ./src/builds/playground.ts",
"build": "pnpm run typecheck && pnpm run build:components && pnpm run build:elements && pnpm run build:functions && pnpm run build:stacks",
"build": "pnpm run typecheck && pnpm run build:components && pnpm run build:elements && pnpm run build:functions && pnpm run build:cli && pnpm run build:stacks",
"build:components": "vite build -c ./src/builds/components.ts",
"build:elements": "vite build -c ./src/builds/elements.ts",
"build:cli": "unbuild ./src/cli/index.ts",
"build:functions": "unbuild ../functions",
"server:functions": "wip",
"server:pages": "nitro build",
"build:stacks": "unbuild",
"build:stacks": "unbuild ./src/index",
"build:playground": "vite build -c ./src/builds/playground.ts",
"stub": "unbuild --stub",
"stub": "unbuild ./src --stub",
"stubs": "pnpm -r --parallel run stub",
"lint": "eslint . && pnpm -r --parallel lint",
"lint:fix": "eslint . --fix && pnpm -r --parallel lint:fix",
Expand Down Expand Up @@ -125,7 +127,6 @@
"rimraf": "^3.0.2",
"simple-git-hooks": "^2.8.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.4",
"unocss": "^0.44.2",
"unplugin-auto-import": "^0.9.3",
"unplugin-vue-components": "^0.21.1",
Expand All @@ -137,7 +138,8 @@
},
"devDependencies": {
"@types/fs-extra": "^9.0.13",
"@unocss/vite": "^0.44.2"
"@unocss/vite": "^0.44.2",
"vitepress": "1.0.0-alpha.4"
},
"build": {
"entries": [
Expand All @@ -146,6 +148,7 @@
],
"clean": true,
"declaration": true,
"externals": ["vitepress", "stacks"],
"rollup": {
"emitCJS": true,
"inlineDependencies": true
Expand Down
6 changes: 6 additions & 0 deletions .stacks/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

// import mri from 'mri'

// eslint-disable-next-line no-console
console.log('Testing this CLI')
2 changes: 2 additions & 0 deletions .stacks/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { parseArgs } from './parse-args'
*/
export async function main(): Promise<void> {
try {
console.log('test artisan')

// Setup global error handlers
process.on('uncaughtException', errorHandler)
process.on('unhandledRejection', errorHandler)
Expand Down
25 changes: 19 additions & 6 deletions .stacks/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export function styleEngine() {
// https://github.com/antfu/unplugin-auto-import
const autoImports = AutoImport({
imports: ['vue', '@vueuse/core',
// {
// {
// TODO: this needs to be dynamically generated
// '@ow3/hello-world-functions': ['count', 'increment', 'isDark', 'toggleDark'],
// }
// }
],
dts: resolve(__dirname, '../types/auto-imports.d.ts'),
eslintrc: {
Expand All @@ -41,13 +41,26 @@ const autoImports = AutoImport({
},
})

const components = (dirPath: string, dtsPath: string) => Components({
const components = (dirPath: string, dtsPath: string, extensions: string[]) => Components({
dirs: [dirPath],
extensions: ['vue'],
extensions,
dts: dtsPath,
})

const Stacks = (componentsDirPath = '../../../components/src', componentsDtsPath = '../types/components.d.ts') => <PluginOption>[
/**
* The parsed command-line arguments
*/
export interface StacksOptions {
componentsSrcPath?: string
dtsPath?: string
extensions?: string[]
}

const Stacks = ({
componentsSrcPath = '../../../components/src',
dtsPath = '../types/components.d.ts',
extensions = ['vue'],
}: StacksOptions) => <PluginOption>[
Inspect(),

UiEngine,
Expand All @@ -56,7 +69,7 @@ const Stacks = (componentsDirPath = '../../../components/src', componentsDtsPath

autoImports,

components(componentsDirPath, componentsDtsPath),
components(componentsSrcPath, dtsPath, extensions),
]

export { resolve, createApp, defineConfig, Stacks, UiEngine, autoImports, components }
6 changes: 6 additions & 0 deletions .stacks/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './core'
export * from './builds'
export * from './styles'
export * from './docs'
export * from './functions'
export * from './config'
4 changes: 2 additions & 2 deletions apps/examples/vue/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ViteConfig } from 'stacks'
import { Stacks, defineConfig } from 'stacks'
import type { ViteConfig } from 'stacks/'
import { Stacks, defineConfig } from 'stacks/'
import alias from 'config/alias'

// https://vitejs.dev/config/
Expand Down
2 changes: 1 addition & 1 deletion config/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

// import type { DocsConfig } from 'stacks'
import type { DocsConfig } from 'stacks'
import type { DocsConfig } from 'stacks/'

const docs: DocsConfig = {
lang: 'en-US',
Expand Down
2 changes: 1 addition & 1 deletion config/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This configuration is used to define your project-specific style guide.
*/

import type { Shortcuts } from 'stacks'
import type { Shortcuts } from 'stacks/'

/**
* Shortcuts provide you with the ability to combine utility names for reusability purposes.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"pnpm": ">=7.5.1"
},
"scripts": {
"artisan": "esno ./.stacks/src/cli/run.ts",
"artisan": "pnpm --filter ./.stacks run artisan",
"make:component": "pnpm --filter ./.stacks run make:component",
"make:function": "pnpm --filter ./.stacks run make:function",
"make:stack": "pnpm --filter ./.stacks run make:stack",
Expand All @@ -55,6 +55,7 @@
"build:elements": "pnpm --filter ./.stacks build:elements",
"build:docs": "pnpm --filter ./.stacks build:docs",
"build:playground": "pnpm --filter ./.stacks build:playground",
"build:cli": "pnpm --filter ./.stacks build:cli",
"build:stacks": "pnpm --filter ./.stacks build:stacks",
"server:functions": "pnpm --filter ./.stacks server:functions",
"server:pages": "pnpm --filter ./.stacks server:pages",
Expand Down
Loading

0 comments on commit 4371c05

Please sign in to comment.