@unocss/webpack 0.12.17 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -13
- package/dist/index.js +23 -20
- package/dist/index.mjs +24 -21
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import * as webpack from 'webpack';
|
|
2
2
|
import { UserConfig, UserConfigDefaults } from '@unocss/core';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
interface PluginConfig<Theme extends {} = {}> extends UserConfig<Theme> {
|
|
6
|
-
/**
|
|
7
|
-
* Patterns that filter the files being extracted.
|
|
8
|
-
*/
|
|
9
|
-
include?: FilterPattern;
|
|
10
|
-
/**
|
|
11
|
-
* Patterns that filter the files NOT being extracted.
|
|
12
|
-
*/
|
|
13
|
-
exclude?: FilterPattern;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface WebpackPluginOptions<Theme extends {} = {}> extends PluginConfig<Theme> {
|
|
4
|
+
interface WebpackPluginOptions<Theme extends {} = {}> extends UserConfig<Theme> {
|
|
17
5
|
}
|
|
18
6
|
declare function defineConfig<Theme extends {}>(config: WebpackPluginOptions<Theme>): WebpackPluginOptions<Theme>;
|
|
19
7
|
declare function WebpackPlugin(configOrPath?: WebpackPluginOptions | string, defaults?: UserConfigDefaults): webpack.WebpackPluginInstance;
|
package/dist/index.js
CHANGED
|
@@ -71,14 +71,26 @@ var INCLUDE_COMMENT = "@unocss-include";
|
|
|
71
71
|
var import_pluginutils = __toModule(require("@rollup/pluginutils"));
|
|
72
72
|
var import_config = __toModule(require("@unocss/config"));
|
|
73
73
|
var import_core = __toModule(require("@unocss/core"));
|
|
74
|
-
function createContext(configOrPath, defaults = {}) {
|
|
75
|
-
const
|
|
76
|
-
let rawConfig =
|
|
77
|
-
const uno = (0, import_core.createGenerator)(
|
|
74
|
+
function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
75
|
+
const loadConfig = (0, import_config.createConfigLoader)(configOrPath, extraConfigSources);
|
|
76
|
+
let rawConfig = {};
|
|
77
|
+
const uno = (0, import_core.createGenerator)(rawConfig, defaults);
|
|
78
|
+
let rollupFilter = (0, import_pluginutils.createFilter)(defaultInclude, defaultExclude);
|
|
78
79
|
const invalidations = [];
|
|
79
80
|
const modules = new import_core.BetterMap();
|
|
80
81
|
const tokens = new Set();
|
|
81
|
-
|
|
82
|
+
const ready = reloadConfig();
|
|
83
|
+
async function reloadConfig() {
|
|
84
|
+
const result = await loadConfig();
|
|
85
|
+
rawConfig = result.config;
|
|
86
|
+
uno.setConfig(rawConfig);
|
|
87
|
+
uno.config.envMode = "dev";
|
|
88
|
+
rollupFilter = (0, import_pluginutils.createFilter)(rawConfig.include || defaultInclude, rawConfig.exclude || defaultExclude);
|
|
89
|
+
tokens.clear();
|
|
90
|
+
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
91
|
+
invalidate();
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
82
94
|
function invalidate() {
|
|
83
95
|
invalidations.forEach((cb) => cb());
|
|
84
96
|
}
|
|
@@ -90,21 +102,15 @@ function createContext(configOrPath, defaults = {}) {
|
|
|
90
102
|
if (tokens.size > len)
|
|
91
103
|
invalidate();
|
|
92
104
|
}
|
|
93
|
-
async function reloadConfig() {
|
|
94
|
-
if (!filepath)
|
|
95
|
-
return;
|
|
96
|
-
rawConfig = (0, import_config.loadConfig)(filepath).config;
|
|
97
|
-
uno.setConfig(rawConfig);
|
|
98
|
-
uno.config.envMode = "dev";
|
|
99
|
-
rollupFilter = (0, import_pluginutils.createFilter)(config.include || defaultInclude, config.exclude || defaultExclude);
|
|
100
|
-
tokens.clear();
|
|
101
|
-
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
102
|
-
invalidate();
|
|
103
|
-
}
|
|
104
105
|
const filter = (code, id) => {
|
|
105
106
|
return code.includes(INCLUDE_COMMENT) || rollupFilter(id);
|
|
106
107
|
};
|
|
108
|
+
async function getConfig() {
|
|
109
|
+
await ready;
|
|
110
|
+
return rawConfig;
|
|
111
|
+
}
|
|
107
112
|
return {
|
|
113
|
+
ready,
|
|
108
114
|
tokens,
|
|
109
115
|
modules,
|
|
110
116
|
invalidate,
|
|
@@ -115,10 +121,7 @@ function createContext(configOrPath, defaults = {}) {
|
|
|
115
121
|
reloadConfig,
|
|
116
122
|
uno,
|
|
117
123
|
extract,
|
|
118
|
-
|
|
119
|
-
return rawConfig;
|
|
120
|
-
},
|
|
121
|
-
configFilepath: filepath
|
|
124
|
+
getConfig
|
|
122
125
|
};
|
|
123
126
|
}
|
|
124
127
|
|
package/dist/index.mjs
CHANGED
|
@@ -41,16 +41,28 @@ var INCLUDE_COMMENT = "@unocss-include";
|
|
|
41
41
|
|
|
42
42
|
// ../plugins-common/context.ts
|
|
43
43
|
import { createFilter } from "@rollup/pluginutils";
|
|
44
|
-
import {
|
|
44
|
+
import { createConfigLoader } from "@unocss/config";
|
|
45
45
|
import { BetterMap, createGenerator } from "@unocss/core";
|
|
46
|
-
function createContext(configOrPath, defaults = {}) {
|
|
47
|
-
const
|
|
48
|
-
let rawConfig =
|
|
49
|
-
const uno = createGenerator(
|
|
46
|
+
function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
47
|
+
const loadConfig = createConfigLoader(configOrPath, extraConfigSources);
|
|
48
|
+
let rawConfig = {};
|
|
49
|
+
const uno = createGenerator(rawConfig, defaults);
|
|
50
|
+
let rollupFilter = createFilter(defaultInclude, defaultExclude);
|
|
50
51
|
const invalidations = [];
|
|
51
52
|
const modules = new BetterMap();
|
|
52
53
|
const tokens = new Set();
|
|
53
|
-
|
|
54
|
+
const ready = reloadConfig();
|
|
55
|
+
async function reloadConfig() {
|
|
56
|
+
const result = await loadConfig();
|
|
57
|
+
rawConfig = result.config;
|
|
58
|
+
uno.setConfig(rawConfig);
|
|
59
|
+
uno.config.envMode = "dev";
|
|
60
|
+
rollupFilter = createFilter(rawConfig.include || defaultInclude, rawConfig.exclude || defaultExclude);
|
|
61
|
+
tokens.clear();
|
|
62
|
+
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
63
|
+
invalidate();
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
54
66
|
function invalidate() {
|
|
55
67
|
invalidations.forEach((cb) => cb());
|
|
56
68
|
}
|
|
@@ -62,21 +74,15 @@ function createContext(configOrPath, defaults = {}) {
|
|
|
62
74
|
if (tokens.size > len)
|
|
63
75
|
invalidate();
|
|
64
76
|
}
|
|
65
|
-
async function reloadConfig() {
|
|
66
|
-
if (!filepath)
|
|
67
|
-
return;
|
|
68
|
-
rawConfig = loadConfig(filepath).config;
|
|
69
|
-
uno.setConfig(rawConfig);
|
|
70
|
-
uno.config.envMode = "dev";
|
|
71
|
-
rollupFilter = createFilter(config.include || defaultInclude, config.exclude || defaultExclude);
|
|
72
|
-
tokens.clear();
|
|
73
|
-
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
74
|
-
invalidate();
|
|
75
|
-
}
|
|
76
77
|
const filter = (code, id) => {
|
|
77
78
|
return code.includes(INCLUDE_COMMENT) || rollupFilter(id);
|
|
78
79
|
};
|
|
80
|
+
async function getConfig() {
|
|
81
|
+
await ready;
|
|
82
|
+
return rawConfig;
|
|
83
|
+
}
|
|
79
84
|
return {
|
|
85
|
+
ready,
|
|
80
86
|
tokens,
|
|
81
87
|
modules,
|
|
82
88
|
invalidate,
|
|
@@ -87,10 +93,7 @@ function createContext(configOrPath, defaults = {}) {
|
|
|
87
93
|
reloadConfig,
|
|
88
94
|
uno,
|
|
89
95
|
extract,
|
|
90
|
-
|
|
91
|
-
return rawConfig;
|
|
92
|
-
},
|
|
93
|
-
configFilepath: filepath
|
|
96
|
+
getConfig
|
|
94
97
|
};
|
|
95
98
|
}
|
|
96
99
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/webpack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "The Webpack plugin for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@rollup/pluginutils": "^4.1.1",
|
|
37
|
-
"@unocss/config": "0.
|
|
38
|
-
"@unocss/core": "0.
|
|
37
|
+
"@unocss/config": "0.14.0",
|
|
38
|
+
"@unocss/core": "0.14.0",
|
|
39
39
|
"unplugin": "^0.2.21",
|
|
40
40
|
"webpack-sources": "^3.2.2"
|
|
41
41
|
},
|