├── playground ├── .npmrc ├── src │ ├── composables │ │ ├── index.ts │ │ └── dark.ts │ ├── pages │ │ ├── [...all].vue │ │ ├── index.vue │ │ ├── hi │ │ │ └── [name].vue │ │ └── README.md │ ├── styles │ │ └── main.css │ ├── main.ts │ ├── components │ │ └── Footer.vue │ ├── locales │ │ └── index.ts │ └── utils.ts ├── public │ ├── favicon.png │ └── favicon.svg ├── .gitignore ├── shims.d.ts ├── netlify.toml ├── components.d.ts ├── manifest.json ├── server │ └── index.js ├── tsconfig.json ├── index.html ├── unocss.config.ts ├── vite.config.ts └── package.json ├── pnpm-workspace.yaml ├── cli.mjs ├── assets ├── kv.png ├── after.png └── before.png ├── test ├── demo │ ├── variables.styl │ ├── variables.scss │ ├── index.css │ ├── index.__unocss_transfer__.css │ ├── use-syntax.scss │ ├── astro.astro │ ├── hover.vue │ ├── classCombine.vue │ ├── styleMaxWidth.vue │ ├── styleWeight.vue │ ├── classChild.vue │ ├── classSpace.vue │ ├── sass-builtin-test.vue │ ├── nth.vue │ ├── test-1.vue │ ├── classAdd.vue │ ├── classTail.vue │ ├── classWeight.vue │ ├── classAttribute.vue │ ├── media.vue │ ├── index.html │ ├── stylus.vue │ ├── sass.vue │ ├── less.vue │ ├── vue.tsx │ ├── use-syntax-test.vue │ ├── test-vue-2.vue │ ├── svelte.svelte │ ├── import-deprecation-test.vue │ ├── mixed-decls-fix-test.vue │ ├── complex6.vue │ ├── demo2.vue │ ├── complex2.vue │ ├── test.vue │ ├── test-vue-1.vue │ ├── complex7.vue │ ├── demo3.vue │ ├── complex5.vue │ └── complex3.vue ├── __snapshots__ │ ├── classSpace.test.ts.snap │ ├── classCombine.test.ts.snap │ ├── styleWeight.test.ts.snap │ ├── classWeight.test.ts.snap │ ├── media.test.ts.snap │ ├── classTail.test.ts.snap │ ├── test-1.test.ts.snap │ ├── vue.test.ts.snap │ ├── complex6.test.ts.snap │ ├── complex2.test.ts.snap │ ├── complex7.test.ts.snap │ ├── test.test.ts.snap │ ├── test-vue.test.ts.snap │ ├── complex3.test.ts.snap │ └── complex5.test.ts.snap ├── transformAstro.test.ts ├── test-vue.test.ts ├── transformHtml.test.ts ├── transformSvelte.test.ts ├── globalCss-object.test.ts ├── file-type-validation.test.ts ├── unplugin-filter.test.ts ├── sass-mixed-decls.test.ts └── transformCode.test.ts ├── .github ├── FUNDING.yml └── workflows │ ├── release.yml │ └── ci.yml ├── .npmrc ├── netlify.toml ├── .editorconfig ├── tsdown.config.ts ├── .gitignore ├── .prettierignore ├── src ├── type.ts ├── wrapperVueTemplate.ts ├── prettierCode.ts ├── index.ts ├── transformAstro.ts ├── transformSvelte.ts ├── compilerCss.ts ├── node-html-parser.ts ├── tail.ts ├── transform.ts ├── transformJsx.ts ├── utils.ts ├── lessCompiler.ts ├── transformInlineStyle.ts ├── transformHtml.ts ├── transformCode.ts ├── stylusCompiler.ts ├── transformMedia.ts ├── transformVue.ts ├── cli.ts ├── unplugin.ts └── sassCompiler.ts ├── .vscode └── launch.json ├── .prettierrc.json ├── tsconfig.json ├── debug-test.vue ├── eslint.config.mjs ├── license ├── scripts └── verifyCommit.ts ├── README_zh.md ├── package.json └── README.md /playground/.npmrc: -------------------------------------------------------------------------------- 1 | shamefully-hoist=true 2 | -------------------------------------------------------------------------------- /playground/src/composables/index.ts: -------------------------------------------------------------------------------- 1 | export * from './dark' 2 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - playground 3 | - examples/* 4 | -------------------------------------------------------------------------------- /cli.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node --no-warnings 2 | import('./dist/cli.cjs') 3 | -------------------------------------------------------------------------------- /assets/kv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-He95/transformToUnoCSS/HEAD/assets/kv.png -------------------------------------------------------------------------------- /playground/src/pages/[...all].vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /test/demo/variables.styl: -------------------------------------------------------------------------------- 1 | $namespace = nihao 2 | 3 | @export 4 | namespace = $namespace 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: Simon-He95 2 | custom: ["https://github.com/Simon-He95/sponsor"] 3 | -------------------------------------------------------------------------------- /assets/after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-He95/transformToUnoCSS/HEAD/assets/after.png -------------------------------------------------------------------------------- /assets/before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-He95/transformToUnoCSS/HEAD/assets/before.png -------------------------------------------------------------------------------- /test/demo/variables.scss: -------------------------------------------------------------------------------- 1 | $primary-color: #ff0000; 2 | $font-size: 16px; 3 | $namespace: nihao 4 | -------------------------------------------------------------------------------- /playground/src/composables/dark.ts: -------------------------------------------------------------------------------- 1 | export const isDark = useDark() 2 | export const toggleDark = useToggle(isDark) 3 | -------------------------------------------------------------------------------- /playground/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Simon-He95/transformToUnoCSS/HEAD/playground/public/favicon.png -------------------------------------------------------------------------------- /test/demo/index.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | button{ 4 | background:red; 5 | } 6 | 7 | .haha{ 8 | background:red 9 | } 10 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | ignore-workspace-root-check=true 2 | shamefully-hoist=false 3 | strict-peer-dependencies=false 4 | auto-install-peers=true 5 | -------------------------------------------------------------------------------- /playground/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vite-ssg-dist 3 | .vite-ssg-temp 4 | *.local 5 | dist 6 | dist-ssr 7 | node_modules 8 | .idea/ 9 | *.log 10 | -------------------------------------------------------------------------------- /test/demo/index.__unocss_transfer__.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | button{ 4 | background:red; 5 | } 6 | .haha{ 7 | background:red 8 | } 9 | 10 | -------------------------------------------------------------------------------- /playground/shims.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import type { DefineComponent } from 'vue' 3 | 4 | const component: DefineComponent<{}, {}, any> 5 | export default component 6 | } 7 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "./playground/dist" 3 | command = "npm run play:build" 4 | functions = "./playground/functions/server.zip" 5 | 6 | [build.environment] 7 | NODE_VERSION = "18" 8 | -------------------------------------------------------------------------------- /test/demo/use-syntax.scss: -------------------------------------------------------------------------------- 1 | // Test file for @use syntax 2 | $test-color: blue; 3 | $test-size: 20px; 4 | 5 | @mixin test-mixin() { 6 | color: $test-color; 7 | font-size: $test-size; 8 | } 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /test/demo/astro.astro: -------------------------------------------------------------------------------- 1 | --- 2 | export const prerender = true; 3 | --- 4 | 5 |
6 |

hi

7 |
8 | 9 | 14 | -------------------------------------------------------------------------------- /tsdown.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsdown' 2 | 3 | export default defineConfig({ 4 | target: 'node14', 5 | format: ['cjs', 'esm'], 6 | clean: true, 7 | dts: true, 8 | platform: 'node', // 明确指定为 Node.js 平台 9 | }) 10 | -------------------------------------------------------------------------------- /playground/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "dist" 3 | command = "npx pnpm run build" 4 | 5 | [build.environment] 6 | NPM_FLAGS = "--version" 7 | NODE_VERSION = "18" 8 | 9 | [[redirects]] 10 | from = "/*" 11 | to = "/index.html" 12 | status = 200 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | node_modules 3 | *.log 4 | idea/ 5 | *.local 6 | .DS_Store 7 | dist 8 | .cache 9 | .idea 10 | .history 11 | logs 12 | &-debug.log 13 | *-error.log 14 | .eslintcache 15 | tmp 16 | 17 | 18 | # Local Netlify folder 19 | .netlify 20 | -------------------------------------------------------------------------------- /test/__snapshots__/classSpace.test.ts.snap: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /test/__snapshots__/classCombine.test.ts.snap: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /test/__snapshots__/styleWeight.test.ts.snap: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | -------------------------------------------------------------------------------- /playground/src/styles/main.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | #app { 4 | margin: 0; 5 | padding: 0; 6 | transition: 0.3s; 7 | } 8 | 9 | html.dark { 10 | background: #121212; 11 | } 12 | 13 | a { 14 | text-decoration: none; 15 | color: pink; 16 | } 17 | a:hover { 18 | color: hsl(0, 97%, 77%); 19 | } 20 | -------------------------------------------------------------------------------- /test/__snapshots__/classWeight.test.ts.snap: -------------------------------------------------------------------------------- 1 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /test/demo/hover.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 16 | -------------------------------------------------------------------------------- /test/__snapshots__/media.test.ts.snap: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 16 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | packages/*/CHANGELOG.md 2 | playground-temp/ 3 | dist/ 4 | temp/ 5 | LICENSE.md 6 | pnpm-lock.yaml 7 | pnpm-workspace.yaml 8 | playground/tsconfig-json-load-error/has-error/tsconfig.json 9 | playground/html/invalid.html 10 | playground/html/valid.html 11 | playground/worker/classic-worker.js 12 | .history 13 | test/ 14 | -------------------------------------------------------------------------------- /test/demo/classCombine.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 17 | -------------------------------------------------------------------------------- /test/demo/styleMaxWidth.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 18 | -------------------------------------------------------------------------------- /test/demo/styleWeight.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 18 | -------------------------------------------------------------------------------- /test/demo/classChild.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 17 | -------------------------------------------------------------------------------- /test/__snapshots__/classTail.test.ts.snap: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /playground/components.d.ts: -------------------------------------------------------------------------------- 1 | // generated by unplugin-vue-components 2 | // We suggest you to commit this file into source control 3 | // Read more: https://github.com/vuejs/vue-next/pull/3399 4 | 5 | declare module 'vue' { 6 | export interface GlobalComponents { 7 | Footer: typeof import('./src/components/Footer.vue')['default'] 8 | } 9 | } 10 | 11 | export { } 12 | -------------------------------------------------------------------------------- /test/demo/classSpace.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 17 | -------------------------------------------------------------------------------- /playground/public/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/type.ts: -------------------------------------------------------------------------------- 1 | import type { FilterPattern } from '@rollup/pluginutils' 2 | 3 | export type SuffixType = 'vue' | 'tsx' | 'html' | 'astro' | 'svelte' 4 | export type CssType = 'less' | 'scss' | 'css' | 'stylus' 5 | 6 | export interface Options { 7 | include?: FilterPattern 8 | exclude?: FilterPattern 9 | // optional resolve alias map from bundler (vite/rollup) config 10 | resolveAlias?: any 11 | } 12 | -------------------------------------------------------------------------------- /test/demo/sass-builtin-test.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 17 | -------------------------------------------------------------------------------- /test/__snapshots__/test-1.test.ts.snap: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | -------------------------------------------------------------------------------- /test/demo/nth.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 19 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "chrome", 9 | "request": "launch", 10 | "name": "针对 localhost 启动 Chrome", 11 | "url": "http://localhost:8080", 12 | "webRoot": "${workspaceFolder}" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/demo/test-1.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /playground/src/pages/index.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/demo/classAdd.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 22 | -------------------------------------------------------------------------------- /test/demo/classTail.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 20 | -------------------------------------------------------------------------------- /playground/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en-us", 3 | "name": "Temperature converter app", 4 | "short_name": "Temperature converter", 5 | "description": "A basic temperature converter application that can convert to and from Celsius, Kelvin, and Fahrenheit", 6 | "start_url": "./", 7 | "background_color": "#2f3d58", 8 | "theme_color": "#2f3d58", 9 | "orientation": "any", 10 | "display": "standalone", 11 | "icons": [] 12 | } 13 | -------------------------------------------------------------------------------- /test/demo/classWeight.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 11 | 12 | 22 | -------------------------------------------------------------------------------- /src/wrapperVueTemplate.ts: -------------------------------------------------------------------------------- 1 | export function wrapperVueTemplate(template: string, css?: string) { 2 | let _template = /