lvyjs 0.2.10 → 0.2.12
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/lib/main.js +8 -3
- package/lib/postcss.js +4 -4
- package/lib/store.d.ts +1 -1
- package/package.json +1 -1
package/lib/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import module from 'node:module';
|
|
2
2
|
import { MessageChannel } from 'node:worker_threads';
|
|
3
3
|
import { postCSS } from './postcss.js';
|
|
4
|
+
import { assetsRegExp, stylesRegExp } from './config.js';
|
|
4
5
|
|
|
5
6
|
if (!module.register) {
|
|
6
7
|
throw new Error(`This version of Node.js (${process.version}) does not support module.register(). Please upgrade to Node v18.19 or v20.6 and above.`);
|
|
@@ -22,9 +23,13 @@ module.register('./loader.js', {
|
|
|
22
23
|
data: {
|
|
23
24
|
port: port2,
|
|
24
25
|
lvyConfig: {
|
|
25
|
-
alias: global.lvyConfig
|
|
26
|
-
assets: global.lvyConfig
|
|
27
|
-
|
|
26
|
+
alias: global.lvyConfig?.alias,
|
|
27
|
+
assets: global.lvyConfig?.assets ?? {
|
|
28
|
+
filter: assetsRegExp
|
|
29
|
+
},
|
|
30
|
+
styles: global.lvyConfig?.styles ?? {
|
|
31
|
+
filter: stylesRegExp
|
|
32
|
+
}
|
|
28
33
|
}
|
|
29
34
|
},
|
|
30
35
|
transferList: [port2]
|
package/lib/postcss.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import postcss from 'postcss';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
4
|
import { join, resolve, dirname, isAbsolute } from 'path';
|
|
5
|
-
import { createAlias } from './config.js';
|
|
5
|
+
import { convertPath, createAlias } from './config.js';
|
|
6
6
|
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
8
|
const config = {
|
|
@@ -60,7 +60,7 @@ const loadPostcssConfig = (configPath, typing) => {
|
|
|
60
60
|
for (const entry of aliasEntries) {
|
|
61
61
|
if (id.startsWith(entry.find)) {
|
|
62
62
|
const aliasedPath = id.replace(entry.find, entry.replacement);
|
|
63
|
-
return resolve(basedir, aliasedPath);
|
|
63
|
+
return convertPath(resolve(basedir, aliasedPath));
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
return id; // 默认返回原始路径
|
|
@@ -77,10 +77,10 @@ const loadPostcssConfig = (configPath, typing) => {
|
|
|
77
77
|
for (const entry of aliasEntries) {
|
|
78
78
|
if (asset.url.startsWith(entry.find)) {
|
|
79
79
|
const aliasedPath = asset.url.replace(entry.find, entry.replacement);
|
|
80
|
-
return aliasedPath;
|
|
80
|
+
return convertPath(aliasedPath);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
return asset.url;
|
|
83
|
+
return convertPath(asset.url);
|
|
84
84
|
}
|
|
85
85
|
}));
|
|
86
86
|
}
|
package/lib/store.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ type PluginsCallBack = PluginsValue | {
|
|
|
8
8
|
load?: PluginsValue;
|
|
9
9
|
build?: PluginsValue;
|
|
10
10
|
};
|
|
11
|
-
type PluginsOptions = (
|
|
11
|
+
type PluginsOptions = (options: Options) => PluginsCallBack | void;
|
|
12
12
|
type Options = {
|
|
13
13
|
/**
|
|
14
14
|
* 配置调整机及其回调插件
|