ms-vite-plugin 0.2.5 → 0.2.6

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/build.js +35 -31
  2. package/package.json +1 -1
package/dist/build.js CHANGED
@@ -108,39 +108,43 @@ function prodReturnMain() {
108
108
  };
109
109
  }
110
110
  const buildAll = async (isDev = true, workspacePath) => {
111
- const obfuscatorConfig = await fsExtra.readJSON(path.join(workspacePath, "obfuscator.json"));
112
- const outputDir = path.join(workspacePath, isDev ? "dist" : "msbundle");
113
- const baseDir = path.join(workspacePath, "scripts");
114
- const entryFiles = await findEntryFiles(baseDir, baseDir);
115
- await fsExtra.remove(outputDir);
116
- for (const entry of entryFiles) {
117
- await (0, vite_1.build)({
118
- root: workspacePath,
119
- build: {
120
- lib: {
121
- entry: {
122
- [path.basename(entry, path.extname(entry))]: `./scripts/${entry}`,
111
+ const isJs = await fsExtra.pathExists(path.join(workspacePath, "scripts", "main.js"));
112
+ if (isJs) {
113
+ console.log("🚀 开始构建JavaScript项目...");
114
+ const obfuscatorConfig = await fsExtra.readJSON(path.join(workspacePath, "obfuscator.json"));
115
+ const outputDir = path.join(workspacePath, isDev ? "dist" : "msbundle");
116
+ const baseDir = path.join(workspacePath, "scripts");
117
+ const entryFiles = await findEntryFiles(baseDir, baseDir);
118
+ await fsExtra.remove(outputDir);
119
+ for (const entry of entryFiles) {
120
+ await (0, vite_1.build)({
121
+ root: workspacePath,
122
+ build: {
123
+ lib: {
124
+ entry: {
125
+ [path.basename(entry, path.extname(entry))]: `./scripts/${entry}`,
126
+ },
127
+ fileName: () => entry,
128
+ formats: ["iife"],
129
+ name: "KuaiJS", // IIFE 格式必需的全局变量名
123
130
  },
124
- fileName: () => entry,
125
- formats: ["iife"],
126
- name: "KuaiJS", // IIFE 格式必需的全局变量名
131
+ outDir: isDev ? "dist/scripts" : "msbundle/scripts",
132
+ emptyOutDir: false, // 不要每次清空输出目录
133
+ sourcemap: isDev,
134
+ minify: !isDev, // 开发环境不压缩变量名
127
135
  },
128
- outDir: isDev ? "dist/scripts" : "msbundle/scripts",
129
- emptyOutDir: false, // 不要每次清空输出目录
130
- sourcemap: isDev,
131
- minify: !isDev, // 开发环境不压缩变量名
132
- },
133
- plugins: isDev
134
- ? [devReturnMain()]
135
- : [
136
- prodReturnMain(),
137
- (0, vite_plugin_bundle_obfuscator_1.default)({
138
- autoExcludeNodeModules: true,
139
- threadPool: true,
140
- options: obfuscatorConfig,
141
- }),
142
- ],
143
- });
136
+ plugins: isDev
137
+ ? [devReturnMain()]
138
+ : [
139
+ prodReturnMain(),
140
+ (0, vite_plugin_bundle_obfuscator_1.default)({
141
+ autoExcludeNodeModules: true,
142
+ threadPool: true,
143
+ options: obfuscatorConfig,
144
+ }),
145
+ ],
146
+ });
147
+ }
144
148
  }
145
149
  if (isDev) {
146
150
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {