Hello 各位好 我是 imba久期
imba97 / hexo-unocss Goto Github PK
View Code? Open in Web Editor NEW支持在文章中使用 UnoCSS | Support using UnoCSS when writing articles
License: MIT License
支持在文章中使用 UnoCSS | Support using UnoCSS when writing articles
License: MIT License
@unocss/core
的 configFile
好像不会加载相应配置
参考源码使用 unconfig
可以获取到配置
import path from 'node:path'
import { createGenerator } from 'unocss'
import { loadConfig } from 'unconfig'
const { config } = await loadConfig({
sources: {
files: path.resolve(process.cwd(), 'uno/uno.config.ts')
}
})
const generator = createGenerator(config)
const { css } = await generator.generate('text-red')
console.log(css)
nice
因为 unocss
只有 .mjs
,hexo
运行时导入报错
ERROR Plugin load failed: hexo-unocss
Error [ERR_REQUIRE_ESM]: require() of ES Module D:\Projects\hexo-unocss-test\node_modules\unocss\dist\index.mjs not supported.
Instead change the require of D:\Projects\hexo-unocss-test\node_modules\unocss\dist\index.mjs to a dynamic import() which is available in all CommonJS modules.
at req (D:\Projects\hexo-unocss-test\node_modules\hexo\dist\hexo\index.js:241:31)
at D:\Projects\hexo-unocss-test\node_modules\hexo-unocss\dist\index.cjs:1:168
at D:\Projects\hexo-unocss-test\node_modules\hexo\dist\hexo\index.js:249:20 at tryCatcher (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\promise.js:729:18)
at _drainQueueStep (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\async.js:102:5)
at Async.drainQueues (D:\Projects\hexo-unocss-test\node_modules\bluebird\js\release\async.js:15:14)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.