Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add defaultUnocssConfig to webpack plugin and unocss vscode extension #1056

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/shared-integration/package.json
Expand Up @@ -4,6 +4,7 @@
"private": true,
"dependencies": {
"@unocss/core": "workspace:*",
"@unocss/preset-uno": "workspace:*",
"@unocss/scope": "workspace:*"
}
}
6 changes: 6 additions & 0 deletions packages/shared-integration/src/defaults.ts
@@ -1,4 +1,10 @@
import type { UserConfigDefaults } from '@unocss/core'
import { cssIdRE } from '@unocss/core'
import presetUno from '@unocss/preset-uno'

export const defaultExclude = [cssIdRE]
export const defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/, /\.elm$/]

export const defaultUnocssConfig: UserConfigDefaults = {
presets: [presetUno()],
}
8 changes: 2 additions & 6 deletions packages/unocss/src/vite.ts
@@ -1,7 +1,7 @@
import type { VitePluginConfig } from '@unocss/vite'
import VitePlugin from '@unocss/vite'
import presetUno from '@unocss/preset-uno'
import type { Plugin } from 'vite'
import { defaultUnocssConfig } from '../../shared-integration/src'

export * from '@unocss/vite'

Expand All @@ -10,10 +10,6 @@ export default function UnocssVitePlugin<Theme extends {}>(
): Plugin[] {
return VitePlugin(
configOrPath,
{
presets: [
presetUno(),
],
},
defaultUnocssConfig,
)
}
6 changes: 3 additions & 3 deletions packages/vscode/src/index.ts
Expand Up @@ -4,7 +4,7 @@ import { StatusBarAlignment, window, workspace } from 'vscode'
import { sourceObjectFields, sourcePluginFactory } from 'unconfig/presets'
import { version } from '../package.json'
import { resolveOptions as resolveNuxtOptions } from '../../nuxt/src/options'
import { createContext } from './integration'
import { createContext, defaultUnocssConfig } from './integration'
import { log } from './log'
import { registerAnnonations } from './annonation'
import { registerAutoComplete } from './autocomplete'
Expand All @@ -21,7 +21,7 @@ export async function activate(ext: ExtensionContext) {
log.appendLine(`UnoCSS for VS Code v${version} ${process.cwd()}`)

const context = createContext(
cwd, {},
cwd, defaultUnocssConfig,
[
sourcePluginFactory({
files: [
Expand Down Expand Up @@ -71,4 +71,4 @@ export async function activate(ext: ExtensionContext) {
registerAnnonations(cwd, context, status, ext)
}

export function deactivate() {}
export function deactivate() { }
1 change: 1 addition & 0 deletions packages/webpack/package.json
Expand Up @@ -43,6 +43,7 @@
"@rollup/pluginutils": "^4.2.1",
"@unocss/config": "workspace:*",
"@unocss/core": "workspace:*",
"@unocss/preset-uno": "workspace:*",
"unplugin": "^0.6.3",
"webpack-sources": "^3.2.3"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/webpack/src/index.ts
Expand Up @@ -7,14 +7,15 @@ import {
LAYER_MARK_ALL,
LAYER_PLACEHOLDER_RE,
createContext,
defaultUnocssConfig,
getHash,
getHashPlaceholder,
getLayerPlaceholder,
getPath,
resolveId,
} from '../../shared-integration/src'

export interface WebpackPluginOptions<Theme extends {} = {}> extends UserConfig<Theme> {}
export interface WebpackPluginOptions<Theme extends {} = {}> extends UserConfig<Theme> { }

const PLUGIN_NAME = 'unocss:webpack'
const UPDATE_DEBOUNCE = 10
Expand All @@ -25,7 +26,7 @@ export function defineConfig<Theme extends {}>(config: WebpackPluginOptions<Them

export default function WebpackPlugin(
configOrPath?: WebpackPluginOptions | string,
defaults?: UserConfigDefaults,
defaults: UserConfigDefaults = defaultUnocssConfig,
) {
return createUnplugin(() => {
const context = createContext(configOrPath, defaults)
Expand Down
4 changes: 4 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.