@vixt/uni 0.3.2 → 0.3.4

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.
Files changed (2) hide show
  1. package/dist/index.mjs +23 -14
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -9,7 +9,6 @@ import Pages from '@uni-helper/vite-plugin-uni-pages';
9
9
  import defu from 'defu';
10
10
  import UnoCSS from 'unocss/vite';
11
11
  import AutoImport from 'unplugin-auto-import/vite';
12
- import path$1 from 'node:path';
13
12
  import { resolvePathSync } from 'mlly';
14
13
  import { readFileSync } from 'node:fs';
15
14
  import process from 'node:process';
@@ -143,10 +142,11 @@ const presetUni = defineVixtModule({
143
142
  }
144
143
  });
145
144
 
146
- function copyUniModules(_, vixt) {
147
- const { srcDir, uniModules: { include, exclude } = {} } = vixt.options;
145
+ function copyUniModules(options, vixt) {
146
+ const { srcDir } = vixt.options;
147
+ const { include, exclude } = options ?? {};
148
148
  const { uni_modules = [] } = resolveLayersDirs(vixt._layers);
149
- const srcUniModulesPath = path$1.join(srcDir, "uni_modules");
149
+ const srcUniModulesPath = path.join(srcDir, "uni_modules");
150
150
  uni_modules.forEach((uniModulesPath) => {
151
151
  fs.readdirSync(uniModulesPath).filter((dir) => {
152
152
  if (include?.length)
@@ -155,23 +155,32 @@ function copyUniModules(_, vixt) {
155
155
  return !exclude.includes(dir);
156
156
  return true;
157
157
  }).forEach((dir) => {
158
- const srcPath = path$1.join(uniModulesPath, dir);
159
- const destPath = path$1.join(srcUniModulesPath, dir);
160
- const srcPkgVersion = fs.readJSONSync(path$1.join(srcPath, "package.json"), { throws: false })?.version;
161
- const destPkgVersion = fs.readJSONSync(path$1.join(destPath, "package.json"), { throws: false })?.version;
162
- if (srcPath !== destPath && srcPkgVersion !== destPkgVersion) {
163
- fs.removeSync(destPath);
158
+ const srcPath = path.join(uniModulesPath, dir);
159
+ const destPath = path.join(srcUniModulesPath, dir);
160
+ if (srcPath !== destPath) {
164
161
  fs.copySync(srcPath, destPath);
165
- fs.writeFileSync(path$1.join(destPath, ".gitignore"), "*", "utf-8");
162
+ fs.writeFileSync(path.join(destPath, ".gitignore"), "*", "utf-8");
166
163
  }
167
164
  });
168
165
  });
169
166
  }
170
167
  const name = "vixt:uni-modules";
171
168
  const uniModules = defineVixtModule({
172
- meta: { name },
173
- setup(_, vixt) {
174
- copyUniModules(_, vixt);
169
+ meta: { name, configKey: "uniModules" },
170
+ setup(options, vixt) {
171
+ copyUniModules(options, vixt);
172
+ return {
173
+ name,
174
+ configureServer(server) {
175
+ const { uni_modules = [] } = resolveLayersDirs(vixt._layers);
176
+ server.watcher.add(uni_modules);
177
+ server.watcher.on("all", (_, file) => {
178
+ const match = uni_modules.some((e) => path.normalize(file).match(e));
179
+ if (match)
180
+ copyUniModules(options, vixt);
181
+ });
182
+ }
183
+ };
175
184
  }
176
185
  });
177
186
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/uni",
3
3
  "type": "module",
4
- "version": "0.3.2",
4
+ "version": "0.3.4",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/SoulLyoko/vixt#readme",
@@ -18,7 +18,7 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@dcloudio/types": "^3.4.14",
21
+ "@dcloudio/types": "^3.4.15",
22
22
  "@uni-helper/uni-app-types": "^1.0.0-alpha.6",
23
23
  "@uni-helper/uni-use": "^0.19.14",
24
24
  "@uni-helper/unocss-preset-uni": "^0.2.11",
@@ -26,8 +26,8 @@
26
26
  "@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
27
27
  "@uni-helper/vite-plugin-uni-pages": "^0.2.28",
28
28
  "unocss-applet": "^0.10.0",
29
- "@vixt/core": "0.3.2",
30
- "@vixt/vue": "0.3.2"
29
+ "@vixt/core": "0.3.4",
30
+ "@vixt/vue": "0.3.4"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "unbuild"