@unocss/webpack 0.14.0 → 0.15.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.js → index.cjs} +33 -61
- package/dist/index.mjs +18 -27
- package/package.json +8 -8
|
@@ -1,50 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __reExport = (target, module2, desc) => {
|
|
14
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(module2))
|
|
16
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
|
-
var __toModule = (module2) => {
|
|
22
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const unplugin = require('unplugin');
|
|
6
|
+
const WebpackSources = require('webpack-sources');
|
|
7
|
+
require('crypto');
|
|
8
|
+
const pluginutils = require('@rollup/pluginutils');
|
|
9
|
+
const config = require('@unocss/config');
|
|
10
|
+
const core = require('@unocss/core');
|
|
24
11
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
defineConfig: () => defineConfig
|
|
29
|
-
});
|
|
30
|
-
var import_unplugin = __toModule(require("unplugin"));
|
|
31
|
-
var import_webpack_sources = __toModule(require("webpack-sources"));
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
13
|
+
|
|
14
|
+
const WebpackSources__default = /*#__PURE__*/_interopDefaultLegacy(WebpackSources);
|
|
32
15
|
|
|
33
|
-
// ../plugins-common/utils.ts
|
|
34
|
-
var import_crypto = __toModule(require("crypto"));
|
|
35
16
|
function getPath(id) {
|
|
36
17
|
return id.replace(/\?.*$/, "");
|
|
37
18
|
}
|
|
38
19
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/];
|
|
20
|
+
const defaultExclude = [/\.(css|postcss|sass|scss|less|stylus|styl)$/];
|
|
21
|
+
const defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/];
|
|
42
22
|
|
|
43
|
-
|
|
44
|
-
var VIRTUAL_ENTRY_ALIAS = [
|
|
23
|
+
const VIRTUAL_ENTRY_ALIAS = [
|
|
45
24
|
/^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/
|
|
46
25
|
];
|
|
47
|
-
|
|
26
|
+
const LAYER_MARK_ALL = "__ALL__";
|
|
48
27
|
function resolveId(id) {
|
|
49
28
|
for (const alias of VIRTUAL_ENTRY_ALIAS) {
|
|
50
29
|
const match = id.match(alias);
|
|
@@ -59,33 +38,28 @@ function resolveId(id) {
|
|
|
59
38
|
}
|
|
60
39
|
}
|
|
61
40
|
}
|
|
62
|
-
|
|
41
|
+
const LAYER_PLACEHOLDER_RE = /(\\?")?#--unocss--\s*{\s*layer\s*:\s*(.+?);?\s*}/g;
|
|
63
42
|
function getLayerPlaceholder(layer) {
|
|
64
43
|
return `#--unocss--{layer:${layer}}`;
|
|
65
44
|
}
|
|
66
45
|
|
|
67
|
-
|
|
68
|
-
var INCLUDE_COMMENT = "@unocss-include";
|
|
46
|
+
const INCLUDE_COMMENT = "@unocss-include";
|
|
69
47
|
|
|
70
|
-
// ../plugins-common/context.ts
|
|
71
|
-
var import_pluginutils = __toModule(require("@rollup/pluginutils"));
|
|
72
|
-
var import_config = __toModule(require("@unocss/config"));
|
|
73
|
-
var import_core = __toModule(require("@unocss/core"));
|
|
74
48
|
function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
75
|
-
const loadConfig =
|
|
49
|
+
const loadConfig = config.createConfigLoader(configOrPath, extraConfigSources);
|
|
76
50
|
let rawConfig = {};
|
|
77
|
-
const uno =
|
|
78
|
-
let rollupFilter =
|
|
51
|
+
const uno = core.createGenerator(rawConfig, defaults);
|
|
52
|
+
let rollupFilter = pluginutils.createFilter(defaultInclude, defaultExclude);
|
|
79
53
|
const invalidations = [];
|
|
80
|
-
const modules = new
|
|
81
|
-
const tokens = new Set();
|
|
54
|
+
const modules = new core.BetterMap();
|
|
55
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
82
56
|
const ready = reloadConfig();
|
|
83
57
|
async function reloadConfig() {
|
|
84
58
|
const result = await loadConfig();
|
|
85
59
|
rawConfig = result.config;
|
|
86
60
|
uno.setConfig(rawConfig);
|
|
87
61
|
uno.config.envMode = "dev";
|
|
88
|
-
rollupFilter =
|
|
62
|
+
rollupFilter = pluginutils.createFilter(rawConfig.include || defaultInclude, rawConfig.exclude || defaultExclude);
|
|
89
63
|
tokens.clear();
|
|
90
64
|
await Promise.all(modules.map((code, id) => uno.applyExtractors(code, id, tokens)));
|
|
91
65
|
invalidate();
|
|
@@ -125,14 +99,13 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
|
125
99
|
};
|
|
126
100
|
}
|
|
127
101
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
var UPDATE_DEBOUNCE = 10;
|
|
102
|
+
const PLUGIN_NAME = "unocss:webpack";
|
|
103
|
+
const UPDATE_DEBOUNCE = 10;
|
|
131
104
|
function defineConfig(config) {
|
|
132
105
|
return config;
|
|
133
106
|
}
|
|
134
107
|
function WebpackPlugin(configOrPath, defaults) {
|
|
135
|
-
return
|
|
108
|
+
return unplugin.createUnplugin(() => {
|
|
136
109
|
const context = createContext(configOrPath, defaults);
|
|
137
110
|
const { uno, tokens, filter, extract, onInvalidate } = context;
|
|
138
111
|
let timer;
|
|
@@ -141,7 +114,7 @@ function WebpackPlugin(configOrPath, defaults) {
|
|
|
141
114
|
timer = setTimeout(updateModules, UPDATE_DEBOUNCE);
|
|
142
115
|
});
|
|
143
116
|
const tasks = [];
|
|
144
|
-
const entries = new Map();
|
|
117
|
+
const entries = /* @__PURE__ */ new Map();
|
|
145
118
|
const plugin = {
|
|
146
119
|
name: "unocss:webpack",
|
|
147
120
|
enforce: "pre",
|
|
@@ -185,7 +158,7 @@ function WebpackPlugin(configOrPath, defaults) {
|
|
|
185
158
|
return quote + escaped;
|
|
186
159
|
});
|
|
187
160
|
if (replaced)
|
|
188
|
-
compilation.assets[file] = new
|
|
161
|
+
compilation.assets[file] = new WebpackSources__default.RawSource(code);
|
|
189
162
|
}
|
|
190
163
|
});
|
|
191
164
|
});
|
|
@@ -207,7 +180,6 @@ function WebpackPlugin(configOrPath, defaults) {
|
|
|
207
180
|
return plugin;
|
|
208
181
|
}).webpack();
|
|
209
182
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
183
|
+
|
|
184
|
+
exports["default"] = WebpackPlugin;
|
|
185
|
+
exports.defineConfig = defineConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { createUnplugin } from 'unplugin';
|
|
2
|
+
import WebpackSources from 'webpack-sources';
|
|
3
|
+
import 'crypto';
|
|
4
|
+
import { createFilter } from '@rollup/pluginutils';
|
|
5
|
+
import { createConfigLoader } from '@unocss/config';
|
|
6
|
+
import { createGenerator, BetterMap } from '@unocss/core';
|
|
4
7
|
|
|
5
|
-
// ../plugins-common/utils.ts
|
|
6
|
-
import { createHash } from "crypto";
|
|
7
8
|
function getPath(id) {
|
|
8
9
|
return id.replace(/\?.*$/, "");
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/];
|
|
12
|
+
const defaultExclude = [/\.(css|postcss|sass|scss|less|stylus|styl)$/];
|
|
13
|
+
const defaultInclude = [/\.vue$/, /\.vue\?vue/, /\.svelte$/, /\.[jt]sx$/, /\.mdx?$/, /\.astro$/];
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
var VIRTUAL_ENTRY_ALIAS = [
|
|
15
|
+
const VIRTUAL_ENTRY_ALIAS = [
|
|
17
16
|
/^(?:virtual:)?uno(?::(.+))?\.css(\?.*)?$/
|
|
18
17
|
];
|
|
19
|
-
|
|
18
|
+
const LAYER_MARK_ALL = "__ALL__";
|
|
20
19
|
function resolveId(id) {
|
|
21
20
|
for (const alias of VIRTUAL_ENTRY_ALIAS) {
|
|
22
21
|
const match = id.match(alias);
|
|
@@ -31,18 +30,13 @@ function resolveId(id) {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
|
|
33
|
+
const LAYER_PLACEHOLDER_RE = /(\\?")?#--unocss--\s*{\s*layer\s*:\s*(.+?);?\s*}/g;
|
|
35
34
|
function getLayerPlaceholder(layer) {
|
|
36
35
|
return `#--unocss--{layer:${layer}}`;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
var INCLUDE_COMMENT = "@unocss-include";
|
|
38
|
+
const INCLUDE_COMMENT = "@unocss-include";
|
|
41
39
|
|
|
42
|
-
// ../plugins-common/context.ts
|
|
43
|
-
import { createFilter } from "@rollup/pluginutils";
|
|
44
|
-
import { createConfigLoader } from "@unocss/config";
|
|
45
|
-
import { BetterMap, createGenerator } from "@unocss/core";
|
|
46
40
|
function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
47
41
|
const loadConfig = createConfigLoader(configOrPath, extraConfigSources);
|
|
48
42
|
let rawConfig = {};
|
|
@@ -50,7 +44,7 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
|
50
44
|
let rollupFilter = createFilter(defaultInclude, defaultExclude);
|
|
51
45
|
const invalidations = [];
|
|
52
46
|
const modules = new BetterMap();
|
|
53
|
-
const tokens = new Set();
|
|
47
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
54
48
|
const ready = reloadConfig();
|
|
55
49
|
async function reloadConfig() {
|
|
56
50
|
const result = await loadConfig();
|
|
@@ -97,9 +91,8 @@ function createContext(configOrPath, defaults = {}, extraConfigSources = []) {
|
|
|
97
91
|
};
|
|
98
92
|
}
|
|
99
93
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var UPDATE_DEBOUNCE = 10;
|
|
94
|
+
const PLUGIN_NAME = "unocss:webpack";
|
|
95
|
+
const UPDATE_DEBOUNCE = 10;
|
|
103
96
|
function defineConfig(config) {
|
|
104
97
|
return config;
|
|
105
98
|
}
|
|
@@ -113,7 +106,7 @@ function WebpackPlugin(configOrPath, defaults) {
|
|
|
113
106
|
timer = setTimeout(updateModules, UPDATE_DEBOUNCE);
|
|
114
107
|
});
|
|
115
108
|
const tasks = [];
|
|
116
|
-
const entries = new Map();
|
|
109
|
+
const entries = /* @__PURE__ */ new Map();
|
|
117
110
|
const plugin = {
|
|
118
111
|
name: "unocss:webpack",
|
|
119
112
|
enforce: "pre",
|
|
@@ -179,7 +172,5 @@ function WebpackPlugin(configOrPath, defaults) {
|
|
|
179
172
|
return plugin;
|
|
180
173
|
}).webpack();
|
|
181
174
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
defineConfig
|
|
185
|
-
};
|
|
175
|
+
|
|
176
|
+
export { WebpackPlugin as default, defineConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/webpack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "The Webpack plugin for UnoCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"require": "./dist/index.
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
25
|
"import": "./dist/index.mjs",
|
|
26
26
|
"types": "./dist/index.d.ts"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"main": "./dist/index.
|
|
29
|
+
"main": "./dist/index.cjs",
|
|
30
30
|
"module": "./dist/index.mjs",
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"files": [
|
|
@@ -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.15.0",
|
|
38
|
+
"@unocss/core": "0.15.0",
|
|
39
39
|
"unplugin": "^0.2.21",
|
|
40
40
|
"webpack-sources": "^3.2.2"
|
|
41
41
|
},
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/webpack": "^5.28.0",
|
|
47
47
|
"@types/webpack-sources": "^3.2.0",
|
|
48
|
-
"webpack": "^5.64.
|
|
48
|
+
"webpack": "^5.64.4"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"build": "
|
|
52
|
-
"
|
|
51
|
+
"build": "unbuild",
|
|
52
|
+
"stub": "unbuild --stub"
|
|
53
53
|
}
|
|
54
54
|
}
|