@vixt/core 0.1.5 → 0.1.7

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 +16 -14
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -151,7 +151,9 @@ function resolveHeadTag(tag, attrs) {
151
151
  }
152
152
  function generateIndexHtml(options, vixt) {
153
153
  const { buildDir, rootDir } = vixt.options;
154
- fs.outputFileSync(path.resolve(rootDir, "index.html"), `<!-- Generated by Vixt -->
154
+ const indexHtmlPath = path.resolve(rootDir, "index.html");
155
+ if (!fs.existsSync(indexHtmlPath))
156
+ fs.outputFileSync(indexHtmlPath, `<!-- Generated by Vixt -->
155
157
  <!-- This file transform from '${buildDir}/index.html' -->
156
158
  `);
157
159
  const { head = {}, rootTag, rootId } = options;
@@ -186,10 +188,12 @@ ${noscriptTemplate}
186
188
  }
187
189
  function generateMainTs(options, vixt) {
188
190
  const { buildDir, rootDir } = vixt.options;
189
- fs.outputFileSync(path.resolve(rootDir, "src", "main.ts"), `// Generated by Vixt
191
+ const mainTsPath = path.resolve(rootDir, "src", "main.ts");
192
+ if (!fs.existsSync(mainTsPath))
193
+ fs.outputFileSync(mainTsPath, `// Generated by Vixt
190
194
  // This file transform from '${buildDir}/main.ts'
191
195
  `);
192
- const cssTemplate = options?.css?.map((css) => `import '${css}'`).join("\n");
196
+ const cssTemplate = options?.css?.map((css) => `import '${css}'`).join("\n") ?? "";
193
197
  let appComponentImportTempate = "";
194
198
  let appConfigsImportTemplate = "";
195
199
  let appConfigsMergeTemplate = "";
@@ -233,6 +237,7 @@ const defaults$1 = {
233
237
  rootId: "app",
234
238
  rootTag: "div",
235
239
  baseURL: "/",
240
+ css: [],
236
241
  head: {
237
242
  meta: [
238
243
  { charset: "utf-8" },
@@ -245,20 +250,18 @@ const app = defineVixtModule({
245
250
  meta: { name: name$2, configKey: "app" },
246
251
  defaults: defaults$1,
247
252
  setup(options, vixt) {
248
- const { buildDir, rootDir } = vixt.options;
249
- fs.outputFileSync(path.resolve(rootDir, "index.html"), `<!-- Generated by Vixt -->
250
- <!-- This file transform from '${buildDir}/index.html' -->
251
- `);
252
- fs.outputFileSync(path.resolve(rootDir, "src", "main.ts"), `// Generated by Vixt
253
- // This file transform from '${buildDir}/main.ts'
254
- `);
253
+ let indexHtmlCode;
254
+ let mainTsCode;
255
255
  return {
256
256
  name: name$2,
257
+ configResolved() {
258
+ indexHtmlCode = generateIndexHtml(options, vixt);
259
+ mainTsCode = generateMainTs(options, vixt);
260
+ },
257
261
  transformIndexHtml: {
258
262
  order: "pre",
259
263
  handler() {
260
- const code = generateIndexHtml(options, vixt);
261
- return code;
264
+ return indexHtmlCode;
262
265
  }
263
266
  },
264
267
  transform: {
@@ -266,8 +269,7 @@ const app = defineVixtModule({
266
269
  handler(_, id) {
267
270
  if (!id.includes("/src/main.ts"))
268
271
  return;
269
- const code = generateMainTs(options, vixt);
270
- return code;
272
+ return mainTsCode;
271
273
  }
272
274
  }
273
275
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/core",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/SoulLyoko/vixt#readme",
@@ -30,10 +30,10 @@
30
30
  "mlly": "1.7.1",
31
31
  "pathe": "^1.1.2",
32
32
  "pkg-types": "^1.1.3",
33
- "tsx": "^4.16.2",
34
- "vite": "^5.3.4",
35
- "vite-plugin-checker": "^0.7.1",
36
- "vue-tsc": "^2.0.26"
33
+ "tsx": "^4.16.4",
34
+ "vite": "^5.3.5",
35
+ "vite-plugin-checker": "^0.7.2",
36
+ "vue-tsc": "^2.0.29"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "unbuild"