weapp-vite 0.0.0 → 0.0.1

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.js'
package/dist/cli.cjs ADDED
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // src/cli.ts
26
+ var import_node_process = __toESM(require("process"), 1);
27
+ var import_commander = require("commander");
28
+ var import_init = require("@weapp-core/init");
29
+
30
+ // src/build.ts
31
+ var import_vite2 = require("vite");
32
+ var import_micromatch = __toESM(require("micromatch"), 1);
33
+ var import_shared3 = require("@weapp-core/shared");
34
+
35
+ // src/utils/scan.ts
36
+ var import_pathe = __toESM(require("pathe"), 1);
37
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
38
+ var import_klaw = __toESM(require("klaw"), 1);
39
+ var import_shared = require("@weapp-core/shared");
40
+ var defaultExcluded = ["**/node_modules/**", "**/miniprogram_npm/**"];
41
+ function searchAppEntry(root) {
42
+ const extensions = ["js", "ts"];
43
+ const appJson = import_pathe.default.resolve(root, "app.json");
44
+ if (import_fs_extra.default.existsSync(appJson)) {
45
+ for (const ext of extensions) {
46
+ const entryPath = import_pathe.default.resolve(root, (0, import_shared.addExtension)("app", `.${ext}`));
47
+ if (import_fs_extra.default.existsSync(entryPath)) {
48
+ return entryPath;
49
+ }
50
+ }
51
+ }
52
+ }
53
+ function removeFileExtension(path3) {
54
+ return path3.replace(/\.[^/.]+$/, "");
55
+ }
56
+ function searchPageEntry(wxmlPath) {
57
+ if (import_fs_extra.default.existsSync(wxmlPath)) {
58
+ const extensions = ["js", "ts"];
59
+ const base = removeFileExtension(wxmlPath);
60
+ for (const ext of extensions) {
61
+ const entryPath = (0, import_shared.addExtension)(base, `.${ext}`);
62
+ if (import_fs_extra.default.existsSync(entryPath)) {
63
+ return entryPath;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ function getWxmlEntry(wxmlPath) {
69
+ const pageEntry = searchPageEntry(wxmlPath);
70
+ if (pageEntry) {
71
+ const jsonPath = (0, import_shared.addExtension)(removeFileExtension(wxmlPath), ".json");
72
+ if (import_fs_extra.default.existsSync(jsonPath) && import_fs_extra.default.readJsonSync(jsonPath).component) {
73
+ return {
74
+ path: pageEntry,
75
+ type: "component"
76
+ };
77
+ }
78
+ return {
79
+ path: pageEntry,
80
+ type: "page"
81
+ };
82
+ }
83
+ }
84
+ async function scanEntries(root, options) {
85
+ const appEntry = searchAppEntry(root);
86
+ function getPath(to) {
87
+ if (options?.relative) {
88
+ return import_pathe.default.relative(root, to);
89
+ }
90
+ return to;
91
+ }
92
+ if (appEntry) {
93
+ const pageEntries = /* @__PURE__ */ new Set();
94
+ const componentEntries = /* @__PURE__ */ new Set();
95
+ for await (const file of (0, import_klaw.default)(root, {
96
+ filter: options?.filter
97
+ })) {
98
+ if (file.stats.isFile()) {
99
+ if (/\.wxml$/.test(file.path)) {
100
+ const entry = getWxmlEntry(file.path);
101
+ if (entry) {
102
+ if (entry.type === "component") {
103
+ componentEntries.add(getPath(entry.path));
104
+ } else if (entry.type === "page") {
105
+ pageEntries.add(getPath(entry.path));
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+ const app = getPath(appEntry);
112
+ return {
113
+ app,
114
+ pages: pageEntries,
115
+ components: componentEntries,
116
+ all: [app, ...pageEntries, ...componentEntries]
117
+ // css: [...cssEntries],
118
+ };
119
+ }
120
+ }
121
+
122
+ // src/utils/index.ts
123
+ var supportedCssLangs = ["wxss", "scss", "less", "sass", "styl"];
124
+ var supportedCssExtensions = supportedCssLangs.map((x) => `.${x}`);
125
+
126
+ // src/plugins/index.ts
127
+ var import_node_path = __toESM(require("path"), 1);
128
+ var import_fs_extra2 = __toESM(require("fs-extra"), 1);
129
+ var import_magic_string = __toESM(require("magic-string"), 1);
130
+ var import_shared2 = require("@weapp-core/shared");
131
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
132
+ var import_vite = require("vite");
133
+ function parseRequest(id) {
134
+ const [filename, rawQuery] = id.split(`?`, 2);
135
+ const query = Object.fromEntries(new URLSearchParams(rawQuery));
136
+ if (query.wxss !== null) {
137
+ query.wxss = true;
138
+ }
139
+ return {
140
+ filename,
141
+ query
142
+ };
143
+ }
144
+ function normalizeCssPath(id) {
145
+ return (0, import_shared2.addExtension)((0, import_shared2.removeExtension)(id), ".wxss");
146
+ }
147
+ function getRealPath(res) {
148
+ if (res.query.wxss) {
149
+ return (0, import_shared2.addExtension)((0, import_shared2.removeExtension)(res.filename), ".wxss");
150
+ }
151
+ return res.filename;
152
+ }
153
+ function vitePluginWeapp(options) {
154
+ const { cwd: cwd2, entries: _entries, src } = (0, import_shared2.defu)(options, {
155
+ src: ""
156
+ });
157
+ const input = _entries.reduce((acc, cur) => {
158
+ acc[relative(cur)] = cur;
159
+ return acc;
160
+ }, {});
161
+ const entries = Array.isArray(_entries) ? new Set(_entries) : _entries;
162
+ function relative(p) {
163
+ return import_node_path.default.relative(cwd2, p);
164
+ }
165
+ const stylesIds = /* @__PURE__ */ new Set();
166
+ let configResolved;
167
+ return [
168
+ {
169
+ name: "weapp-vite:pre",
170
+ enforce: "pre",
171
+ configResolved(config) {
172
+ config.build.rollupOptions.input = input;
173
+ config.build.rollupOptions.output = {
174
+ format: "cjs",
175
+ entryFileNames: (chunkInfo) => {
176
+ return chunkInfo.name;
177
+ }
178
+ };
179
+ config.build.assetsDir = ".";
180
+ config.build.commonjsOptions.transformMixedEsModules = true;
181
+ configResolved = config;
182
+ },
183
+ resolveId(source) {
184
+ if (/\.wxss$/.test(source)) {
185
+ return source.replace(/\.wxss$/, ".css?wxss");
186
+ }
187
+ },
188
+ load(id) {
189
+ if (entries.has(id)) {
190
+ const base = (0, import_shared2.removeExtension)(id);
191
+ const ms = new import_magic_string.default(import_fs_extra2.default.readFileSync(id, "utf8"));
192
+ for (const ext of supportedCssExtensions) {
193
+ const mayBeCssPath = (0, import_shared2.addExtension)(base, ext);
194
+ if (import_fs_extra2.default.existsSync(mayBeCssPath)) {
195
+ ms.prepend(`import '${mayBeCssPath}'
196
+ `);
197
+ }
198
+ }
199
+ return {
200
+ code: ms.toString()
201
+ };
202
+ } else if ((0, import_vite.isCSSRequest)(id)) {
203
+ stylesIds.add(id);
204
+ return {
205
+ code: ""
206
+ };
207
+ }
208
+ },
209
+ async buildEnd() {
210
+ const styles = {};
211
+ for (const stylesId of stylesIds) {
212
+ const parsed = parseRequest(stylesId);
213
+ const css = await import_fs_extra2.default.readFile(getRealPath(parsed), "utf8");
214
+ const res = await (0, import_vite.preprocessCSS)(css, stylesId, configResolved);
215
+ const fileName = relative(normalizeCssPath(stylesId));
216
+ if (styles[fileName]) {
217
+ styles[fileName] += res.code;
218
+ } else {
219
+ styles[fileName] = res.code;
220
+ }
221
+ }
222
+ for (const style of Object.entries(styles)) {
223
+ this.emitFile({
224
+ type: "asset",
225
+ fileName: style[0],
226
+ source: style[1]
227
+ });
228
+ }
229
+ const files = await (0, import_fast_glob.default)(
230
+ [import_node_path.default.join(src, "**/*.{wxml,json,png,jpg,jpeg,gif,svg,webp}")],
231
+ {
232
+ cwd: cwd2,
233
+ ignore: [
234
+ ...defaultExcluded,
235
+ "dist/**",
236
+ "project.config.json",
237
+ "project.private.config.json",
238
+ "package.json"
239
+ ]
240
+ }
241
+ );
242
+ for (const file of files) {
243
+ this.emitFile({
244
+ type: "asset",
245
+ fileName: file,
246
+ source: await import_fs_extra2.default.readFile(import_node_path.default.resolve(cwd2, file))
247
+ });
248
+ }
249
+ }
250
+ },
251
+ {
252
+ name: "weapp-vite"
253
+ },
254
+ {
255
+ name: "weapp-vite:post",
256
+ enforce: "post"
257
+ }
258
+ ];
259
+ }
260
+
261
+ // src/build.ts
262
+ function createFilter(include, exclude, options) {
263
+ const opts = (0, import_shared3.defu)(options, {
264
+ ignore: exclude
265
+ });
266
+ return function(id) {
267
+ if (typeof id !== "string") {
268
+ return false;
269
+ }
270
+ if (/\0/.test(id)) {
271
+ return false;
272
+ }
273
+ return import_micromatch.default.isMatch(id, include, opts);
274
+ };
275
+ }
276
+ async function runDev(cwd2) {
277
+ const filter = createFilter(["**/*"], [...defaultExcluded, "dist/**"]);
278
+ const entries = await scanEntries(cwd2, { filter });
279
+ if (entries) {
280
+ const watcher = await (0, import_vite2.build)({
281
+ plugins: [
282
+ vitePluginWeapp({
283
+ cwd: cwd2,
284
+ entries: entries.all
285
+ })
286
+ ],
287
+ build: {
288
+ watch: {},
289
+ minify: false
290
+ }
291
+ });
292
+ return watcher;
293
+ }
294
+ }
295
+ async function runProd(cwd2) {
296
+ const filter = createFilter(["**/*"], [...defaultExcluded, "dist/**"]);
297
+ const entries = await scanEntries(cwd2, { filter });
298
+ if (entries) {
299
+ const output = await (0, import_vite2.build)({
300
+ plugins: [
301
+ vitePluginWeapp({
302
+ cwd: cwd2,
303
+ entries: entries.all
304
+ })
305
+ ]
306
+ });
307
+ return output;
308
+ }
309
+ }
310
+
311
+ // src/cli.ts
312
+ var cwd = import_node_process.default.cwd();
313
+ import_commander.program.command("dev").action(async () => {
314
+ await runDev(cwd);
315
+ });
316
+ import_commander.program.command("build").action(async () => {
317
+ await runProd(cwd);
318
+ });
319
+ import_commander.program.command("init").action(() => {
320
+ (0, import_init.initConfig)({
321
+ root: cwd,
322
+ command: "weapp-vite"
323
+ });
324
+ });
325
+ import_commander.program.parse();
package/dist/cli.d.cts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.js ADDED
@@ -0,0 +1,301 @@
1
+ // src/cli.ts
2
+ import process from "node:process";
3
+ import { program } from "commander";
4
+ import { initConfig } from "@weapp-core/init";
5
+
6
+ // src/build.ts
7
+ import { build } from "vite";
8
+ import mm from "micromatch";
9
+ import { defu as defu2 } from "@weapp-core/shared";
10
+
11
+ // src/utils/scan.ts
12
+ import path from "pathe";
13
+ import fs from "fs-extra";
14
+ import klaw from "klaw";
15
+ import { addExtension } from "@weapp-core/shared";
16
+ var defaultExcluded = ["**/node_modules/**", "**/miniprogram_npm/**"];
17
+ function searchAppEntry(root) {
18
+ const extensions = ["js", "ts"];
19
+ const appJson = path.resolve(root, "app.json");
20
+ if (fs.existsSync(appJson)) {
21
+ for (const ext of extensions) {
22
+ const entryPath = path.resolve(root, addExtension("app", `.${ext}`));
23
+ if (fs.existsSync(entryPath)) {
24
+ return entryPath;
25
+ }
26
+ }
27
+ }
28
+ }
29
+ function removeFileExtension(path3) {
30
+ return path3.replace(/\.[^/.]+$/, "");
31
+ }
32
+ function searchPageEntry(wxmlPath) {
33
+ if (fs.existsSync(wxmlPath)) {
34
+ const extensions = ["js", "ts"];
35
+ const base = removeFileExtension(wxmlPath);
36
+ for (const ext of extensions) {
37
+ const entryPath = addExtension(base, `.${ext}`);
38
+ if (fs.existsSync(entryPath)) {
39
+ return entryPath;
40
+ }
41
+ }
42
+ }
43
+ }
44
+ function getWxmlEntry(wxmlPath) {
45
+ const pageEntry = searchPageEntry(wxmlPath);
46
+ if (pageEntry) {
47
+ const jsonPath = addExtension(removeFileExtension(wxmlPath), ".json");
48
+ if (fs.existsSync(jsonPath) && fs.readJsonSync(jsonPath).component) {
49
+ return {
50
+ path: pageEntry,
51
+ type: "component"
52
+ };
53
+ }
54
+ return {
55
+ path: pageEntry,
56
+ type: "page"
57
+ };
58
+ }
59
+ }
60
+ async function scanEntries(root, options) {
61
+ const appEntry = searchAppEntry(root);
62
+ function getPath(to) {
63
+ if (options?.relative) {
64
+ return path.relative(root, to);
65
+ }
66
+ return to;
67
+ }
68
+ if (appEntry) {
69
+ const pageEntries = /* @__PURE__ */ new Set();
70
+ const componentEntries = /* @__PURE__ */ new Set();
71
+ for await (const file of klaw(root, {
72
+ filter: options?.filter
73
+ })) {
74
+ if (file.stats.isFile()) {
75
+ if (/\.wxml$/.test(file.path)) {
76
+ const entry = getWxmlEntry(file.path);
77
+ if (entry) {
78
+ if (entry.type === "component") {
79
+ componentEntries.add(getPath(entry.path));
80
+ } else if (entry.type === "page") {
81
+ pageEntries.add(getPath(entry.path));
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
87
+ const app = getPath(appEntry);
88
+ return {
89
+ app,
90
+ pages: pageEntries,
91
+ components: componentEntries,
92
+ all: [app, ...pageEntries, ...componentEntries]
93
+ // css: [...cssEntries],
94
+ };
95
+ }
96
+ }
97
+
98
+ // src/utils/index.ts
99
+ var supportedCssLangs = ["wxss", "scss", "less", "sass", "styl"];
100
+ var supportedCssExtensions = supportedCssLangs.map((x) => `.${x}`);
101
+
102
+ // src/plugins/index.ts
103
+ import path2 from "node:path";
104
+ import fs2 from "fs-extra";
105
+ import MagicString from "magic-string";
106
+ import { addExtension as addExtension2, defu, removeExtension } from "@weapp-core/shared";
107
+ import fg from "fast-glob";
108
+ import { isCSSRequest, preprocessCSS } from "vite";
109
+ function parseRequest(id) {
110
+ const [filename, rawQuery] = id.split(`?`, 2);
111
+ const query = Object.fromEntries(new URLSearchParams(rawQuery));
112
+ if (query.wxss !== null) {
113
+ query.wxss = true;
114
+ }
115
+ return {
116
+ filename,
117
+ query
118
+ };
119
+ }
120
+ function normalizeCssPath(id) {
121
+ return addExtension2(removeExtension(id), ".wxss");
122
+ }
123
+ function getRealPath(res) {
124
+ if (res.query.wxss) {
125
+ return addExtension2(removeExtension(res.filename), ".wxss");
126
+ }
127
+ return res.filename;
128
+ }
129
+ function vitePluginWeapp(options) {
130
+ const { cwd: cwd2, entries: _entries, src } = defu(options, {
131
+ src: ""
132
+ });
133
+ const input = _entries.reduce((acc, cur) => {
134
+ acc[relative(cur)] = cur;
135
+ return acc;
136
+ }, {});
137
+ const entries = Array.isArray(_entries) ? new Set(_entries) : _entries;
138
+ function relative(p) {
139
+ return path2.relative(cwd2, p);
140
+ }
141
+ const stylesIds = /* @__PURE__ */ new Set();
142
+ let configResolved;
143
+ return [
144
+ {
145
+ name: "weapp-vite:pre",
146
+ enforce: "pre",
147
+ configResolved(config) {
148
+ config.build.rollupOptions.input = input;
149
+ config.build.rollupOptions.output = {
150
+ format: "cjs",
151
+ entryFileNames: (chunkInfo) => {
152
+ return chunkInfo.name;
153
+ }
154
+ };
155
+ config.build.assetsDir = ".";
156
+ config.build.commonjsOptions.transformMixedEsModules = true;
157
+ configResolved = config;
158
+ },
159
+ resolveId(source) {
160
+ if (/\.wxss$/.test(source)) {
161
+ return source.replace(/\.wxss$/, ".css?wxss");
162
+ }
163
+ },
164
+ load(id) {
165
+ if (entries.has(id)) {
166
+ const base = removeExtension(id);
167
+ const ms = new MagicString(fs2.readFileSync(id, "utf8"));
168
+ for (const ext of supportedCssExtensions) {
169
+ const mayBeCssPath = addExtension2(base, ext);
170
+ if (fs2.existsSync(mayBeCssPath)) {
171
+ ms.prepend(`import '${mayBeCssPath}'
172
+ `);
173
+ }
174
+ }
175
+ return {
176
+ code: ms.toString()
177
+ };
178
+ } else if (isCSSRequest(id)) {
179
+ stylesIds.add(id);
180
+ return {
181
+ code: ""
182
+ };
183
+ }
184
+ },
185
+ async buildEnd() {
186
+ const styles = {};
187
+ for (const stylesId of stylesIds) {
188
+ const parsed = parseRequest(stylesId);
189
+ const css = await fs2.readFile(getRealPath(parsed), "utf8");
190
+ const res = await preprocessCSS(css, stylesId, configResolved);
191
+ const fileName = relative(normalizeCssPath(stylesId));
192
+ if (styles[fileName]) {
193
+ styles[fileName] += res.code;
194
+ } else {
195
+ styles[fileName] = res.code;
196
+ }
197
+ }
198
+ for (const style of Object.entries(styles)) {
199
+ this.emitFile({
200
+ type: "asset",
201
+ fileName: style[0],
202
+ source: style[1]
203
+ });
204
+ }
205
+ const files = await fg(
206
+ [path2.join(src, "**/*.{wxml,json,png,jpg,jpeg,gif,svg,webp}")],
207
+ {
208
+ cwd: cwd2,
209
+ ignore: [
210
+ ...defaultExcluded,
211
+ "dist/**",
212
+ "project.config.json",
213
+ "project.private.config.json",
214
+ "package.json"
215
+ ]
216
+ }
217
+ );
218
+ for (const file of files) {
219
+ this.emitFile({
220
+ type: "asset",
221
+ fileName: file,
222
+ source: await fs2.readFile(path2.resolve(cwd2, file))
223
+ });
224
+ }
225
+ }
226
+ },
227
+ {
228
+ name: "weapp-vite"
229
+ },
230
+ {
231
+ name: "weapp-vite:post",
232
+ enforce: "post"
233
+ }
234
+ ];
235
+ }
236
+
237
+ // src/build.ts
238
+ function createFilter(include, exclude, options) {
239
+ const opts = defu2(options, {
240
+ ignore: exclude
241
+ });
242
+ return function(id) {
243
+ if (typeof id !== "string") {
244
+ return false;
245
+ }
246
+ if (/\0/.test(id)) {
247
+ return false;
248
+ }
249
+ return mm.isMatch(id, include, opts);
250
+ };
251
+ }
252
+ async function runDev(cwd2) {
253
+ const filter = createFilter(["**/*"], [...defaultExcluded, "dist/**"]);
254
+ const entries = await scanEntries(cwd2, { filter });
255
+ if (entries) {
256
+ const watcher = await build({
257
+ plugins: [
258
+ vitePluginWeapp({
259
+ cwd: cwd2,
260
+ entries: entries.all
261
+ })
262
+ ],
263
+ build: {
264
+ watch: {},
265
+ minify: false
266
+ }
267
+ });
268
+ return watcher;
269
+ }
270
+ }
271
+ async function runProd(cwd2) {
272
+ const filter = createFilter(["**/*"], [...defaultExcluded, "dist/**"]);
273
+ const entries = await scanEntries(cwd2, { filter });
274
+ if (entries) {
275
+ const output = await build({
276
+ plugins: [
277
+ vitePluginWeapp({
278
+ cwd: cwd2,
279
+ entries: entries.all
280
+ })
281
+ ]
282
+ });
283
+ return output;
284
+ }
285
+ }
286
+
287
+ // src/cli.ts
288
+ var cwd = process.cwd();
289
+ program.command("dev").action(async () => {
290
+ await runDev(cwd);
291
+ });
292
+ program.command("build").action(async () => {
293
+ await runProd(cwd);
294
+ });
295
+ program.command("init").action(() => {
296
+ initConfig({
297
+ root: cwd,
298
+ command: "weapp-vite"
299
+ });
300
+ });
301
+ program.parse();
package/dist/index.cjs CHANGED
@@ -20,17 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- default: () => vitePluginWeapp
23
+ defineConfig: () => defineConfig
24
24
  });
25
25
  module.exports = __toCommonJS(src_exports);
26
- function vitePluginWeapp() {
27
- return [
28
- {
29
- name: "vite-plugin-weapp",
30
- configResolved(config) {
31
- config.server.open ||= false;
32
- config.server.watch ||= {};
33
- }
34
- }
35
- ];
26
+ function defineConfig(config) {
27
+ return config;
36
28
  }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ defineConfig
32
+ });
package/dist/index.d.cts CHANGED
@@ -1,5 +1,8 @@
1
- import { Plugin } from 'vite';
1
+ import { UserConfig, UserConfigFnObject, UserConfigExport } from 'vite';
2
2
 
3
- declare function vitePluginWeapp(): Plugin[];
3
+ declare function defineConfig(config: UserConfig): UserConfig;
4
+ declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
5
+ declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
6
+ declare function defineConfig(config: UserConfigExport): UserConfigExport;
4
7
 
5
- export { vitePluginWeapp as default };
8
+ export { defineConfig };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { Plugin } from 'vite';
1
+ import { UserConfig, UserConfigFnObject, UserConfigExport } from 'vite';
2
2
 
3
- declare function vitePluginWeapp(): Plugin[];
3
+ declare function defineConfig(config: UserConfig): UserConfig;
4
+ declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
5
+ declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
6
+ declare function defineConfig(config: UserConfigExport): UserConfigExport;
4
7
 
5
- export { vitePluginWeapp as default };
8
+ export { defineConfig };
package/dist/index.js CHANGED
@@ -1,15 +1,7 @@
1
1
  // src/index.ts
2
- function vitePluginWeapp() {
3
- return [
4
- {
5
- name: "vite-plugin-weapp",
6
- configResolved(config) {
7
- config.server.open ||= false;
8
- config.server.watch ||= {};
9
- }
10
- }
11
- ];
2
+ function defineConfig(config) {
3
+ return config;
12
4
  }
13
5
  export {
14
- vitePluginWeapp as default
6
+ defineConfig
15
7
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "0.0.0",
4
+ "version": "0.0.1",
5
5
  "description": "WIP",
6
6
  "author": "SonOfMagic <qq1324318532@gmail.com>",
7
7
  "license": "MIT",
@@ -20,9 +20,9 @@
20
20
  "require": "./dist/index.cjs"
21
21
  }
22
22
  },
23
- "main": "./dist/index.cjs",
24
- "module": "./dist/index.js",
25
- "types": "./dist/index.d.ts",
23
+ "bin": {
24
+ "weapp-vite": "bin/weapp-vite.js"
25
+ },
26
26
  "files": [
27
27
  "dist"
28
28
  ],
@@ -30,9 +30,16 @@
30
30
  "vite": ">=2.6.0"
31
31
  },
32
32
  "dependencies": {
33
- "@rollup/pluginutils": "^5.1.0",
33
+ "commander": "^12.1.0",
34
+ "debug": "^4.3.6",
34
35
  "fast-glob": "^3.3.2",
35
- "fs-extra": "^11.2.0"
36
+ "fs-extra": "^11.2.0",
37
+ "klaw": "^4.1.0",
38
+ "magic-string": "^0.30.11",
39
+ "micromatch": "^4.0.7",
40
+ "pathe": "^1.1.2",
41
+ "@weapp-core/init": "^0.0.1",
42
+ "@weapp-core/shared": "^0.0.1"
36
43
  },
37
44
  "publishConfig": {
38
45
  "access": "public",
@@ -44,5 +51,8 @@
44
51
  "release": "node scripts/release.js",
45
52
  "test:dev": "vitest",
46
53
  "test": "vitest run"
47
- }
54
+ },
55
+ "main": "./dist/index.cjs",
56
+ "module": "./dist/index.js",
57
+ "types": "./dist/index.d.ts"
48
58
  }