@unocss/webpack
Advanced tools
Comparing version
@@ -75,9 +75,21 @@ var __create = Object.create; | ||
function createContext(configOrPath, defaults = {}) { | ||
const { config = {}, filepath } = (0, import_config.loadConfig)(configOrPath); | ||
let rawConfig = config; | ||
const uno = (0, import_core.createGenerator)(config, defaults); | ||
const loadConfig = (0, import_config.createConfigLoader)(configOrPath); | ||
let rawConfig = {}; | ||
const uno = (0, import_core.createGenerator)(rawConfig, defaults); | ||
let rollupFilter = (0, import_pluginutils.createFilter)(defaultInclude, defaultExclude); | ||
const invalidations = []; | ||
const modules = new import_core.BetterMap(); | ||
const tokens = new Set(); | ||
let rollupFilter = (0, import_pluginutils.createFilter)(config.include || defaultInclude, config.exclude || defaultExclude); | ||
const ready = reloadConfig(); | ||
async function reloadConfig() { | ||
const result = await loadConfig(); | ||
rawConfig = result.config; | ||
uno.setConfig(rawConfig); | ||
uno.config.envMode = "dev"; | ||
rollupFilter = (0, import_pluginutils.createFilter)(rawConfig.include || defaultInclude, rawConfig.exclude || defaultExclude); | ||
tokens.clear(); | ||
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens))); | ||
invalidate(); | ||
return result; | ||
} | ||
function invalidate() { | ||
@@ -94,17 +106,11 @@ invalidations.forEach((cb) => cb()); | ||
} | ||
async function reloadConfig() { | ||
if (!filepath) | ||
return; | ||
rawConfig = (0, import_config.loadConfig)(filepath).config; | ||
uno.setConfig(rawConfig); | ||
uno.config.envMode = "dev"; | ||
rollupFilter = (0, import_pluginutils.createFilter)(config.include || defaultInclude, config.exclude || defaultExclude); | ||
tokens.clear(); | ||
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens))); | ||
invalidate(); | ||
} | ||
const filter = (code, id) => { | ||
return code.includes(INCLUDE_COMMENT) || rollupFilter(id); | ||
}; | ||
async function getConfig() { | ||
await ready; | ||
return rawConfig; | ||
} | ||
return { | ||
ready, | ||
tokens, | ||
@@ -120,6 +126,3 @@ modules, | ||
extract, | ||
get config() { | ||
return rawConfig; | ||
}, | ||
configFilepath: filepath | ||
getConfig | ||
}; | ||
@@ -126,0 +129,0 @@ } |
{ | ||
"name": "@unocss/webpack", | ||
"version": "0.12.18", | ||
"version": "0.13.0", | ||
"description": "The Webpack plugin for UnoCSS", | ||
@@ -37,4 +37,4 @@ "keywords": [ | ||
"@rollup/pluginutils": "^4.1.1", | ||
"@unocss/config": "0.12.18", | ||
"@unocss/core": "0.12.18", | ||
"@unocss/config": "0.13.0", | ||
"@unocss/core": "0.13.0", | ||
"unplugin": "^0.2.21", | ||
@@ -41,0 +41,0 @@ "webpack-sources": "^3.2.2" |
Sorry, the diff of this file is not supported yet
16706
0.22%403
1.51%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated