@open-xchange/vite-plugin-ox-manifests 0.4.4-pre3 → 0.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/vite-plugin-ox-manifests",
3
- "version": "0.4.4-pre3",
3
+ "version": "0.4.6",
4
4
  "description": "A vite plugin to concat and serve ox manifests",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,7 +1,7 @@
1
1
  import path from 'path'
2
2
  import fs from 'fs'
3
3
  import fastGlob from 'fast-glob'
4
- import { applyInputToOptions, basepath } from '../util.js'
4
+ import { applyInputToOptions, basepath, joinUrlPaths } from '../util.js'
5
5
 
6
6
  async function getManifestEntryFile (basePath, extensions) {
7
7
  if (path.extname(basePath)) {
@@ -81,12 +81,12 @@ export default function ({ supportedEntryExtensions, entryPoints, manifestsAsEnt
81
81
  const manifests = [].concat(json)
82
82
  const manifestDir = path.dirname(entry).substr(root.length + 1)
83
83
 
84
- await Promise.all(manifests.map(async ({ path: srcManifestEntryPath = path.join(manifestDir, 'register'), ...rest }) => {
85
- const { dir, base } = await getManifestEntryFile(path.join(root, srcManifestEntryPath), supportedEntryExtensions)
86
- const manifestEntryPath = path.join(dir, base)
84
+ await Promise.all(manifests.map(async ({ path: srcManifestEntryPath = joinUrlPaths(manifestDir, 'register'), ...rest }) => {
85
+ const { dir, base } = await getManifestEntryFile(joinUrlPaths(root, srcManifestEntryPath), supportedEntryExtensions)
86
+ const manifestEntryPath = joinUrlPaths(dir, base)
87
87
 
88
88
  if (manifestsAsEntryPoints) {
89
- input[basepath(path.join(path.dirname(srcManifestEntryPath), base))] = manifestEntryPath
89
+ input[basepath(joinUrlPaths(path.dirname(srcManifestEntryPath), base))] = manifestEntryPath
90
90
  }
91
91
 
92
92
  // 3. put the file content except path into the manifest modules
@@ -2,7 +2,12 @@ import { PROJECT_NAME as name } from '../constants.js'
2
2
  import MagicString from 'magic-string'
3
3
 
4
4
  export default function ({ transformAbsolutePaths } = {}) {
5
+ let resolvedConfig
5
6
  return {
7
+ configResolved (config) {
8
+ resolvedConfig = config
9
+ },
10
+
6
11
  transform (code, id) {
7
12
  if (id === 'vite/preload-helper') {
8
13
  // 2.5.2 transformation
@@ -22,6 +27,7 @@ export default function ({ transformAbsolutePaths } = {}) {
22
27
 
23
28
  transformIndexHtml (src) {
24
29
  if (!transformAbsolutePaths) return src
30
+ if (resolvedConfig.mode !== 'production') return src
25
31
 
26
32
  return src
27
33
  .replace(/(<link[^>]*href="?)(\/)/g, '$1.$2')
package/src/util.js CHANGED
@@ -17,9 +17,13 @@ export function applyInputToOptions (input, options) {
17
17
  }
18
18
  }
19
19
 
20
+ export function joinUrlPaths (...paths) {
21
+ return path.join.apply(path, paths).replace(/\\+/g, '/')
22
+ }
23
+
20
24
  export function basepath (src) {
21
25
  const { dir, name } = path.parse(src)
22
- return path.join(dir, name)
26
+ return joinUrlPaths(dir, name)
23
27
  }
24
28
 
25
29
  export function deepMergeObject (a, b) {