mod-build 4.0.1-beta.6 → 4.0.1-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "4.0.1-beta.6",
3
+ "version": "4.0.1-beta.7",
4
4
  "description": "Share components for S3 sites.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,7 +1,6 @@
1
1
  import fs from "node:fs";
2
2
  import merge from "lodash.merge";
3
3
  import gulpHandlebarsFileInclude from "gulp-handlebars-file-include";
4
- import { glob } from 'glob'
5
4
  import { defaultSettings } from "../data/config.js";
6
5
  import footer from '../data/footer.js';
7
6
  import { handlebarsHelpers } from "./utils.js";
@@ -80,29 +79,4 @@ export const updateConfig = async (config) => {
80
79
  gulpHandlebarsFileInclude(mergedConfig, { handlebarsHelpers, maxRecursion: 500 });
81
80
  }
82
81
  }
83
- }
84
-
85
- export const replaceSrcPaths = (config) => {
86
- return {
87
- name: 'replace-src-paths',
88
- writeBundle: async () => {
89
- const files = glob.sync(defaultSettings.distFolder + '/**/index.html');
90
- for (const file of files) {
91
- let html = await fs.promises.readFile(file, 'utf-8');
92
- let updatedHtml = '';
93
-
94
- if (config.pathSubdirectory && config.pathSubdirectory.length > 0) {
95
- updatedHtml = html
96
- .replace(/(src|data-load)="\/?src\//g, `$1="${config.pathSubdirectory}`)
97
- .replace(/(src|srcset|data-load|href)="\/?assets\//g, `$1="${config.pathSubdirectory}assets/`)
98
- .replace(/(src|data-load|href)="\/?resources\//g, `$1="${config.pathSubdirectory}resources/`)
99
- } else {
100
- updatedHtml = html.replace(/(src|data-load)="\/?src\//g, '$1="/');
101
- }
102
-
103
- await fs.promises.writeFile(file, updatedHtml);
104
- }
105
- },
106
- apply: 'build',
107
- }
108
82
  }
package/vite.config.js CHANGED
@@ -4,8 +4,10 @@ import eslint from 'vite-plugin-eslint'
4
4
  import { defaultSettings } from './src/data/config.js'
5
5
  import { defineConfig } from 'vite'
6
6
  import { startModBuild } from './tasks/serve.js'
7
- import { updateConfig, replaceSrcPaths, STATIC_COPY_TARGETS } from './src/scripts/plugins.js'
7
+ import { updateConfig, STATIC_COPY_TARGETS } from './src/scripts/plugins.js'
8
8
  import { viteStaticCopy } from 'vite-plugin-static-copy'
9
+ import { glob } from 'glob'
10
+ import fs from "node:fs";
9
11
 
10
12
  export default defineConfig((config) => ({
11
13
  build: {
@@ -39,7 +41,28 @@ export default defineConfig((config) => ({
39
41
  apply: 'serve',
40
42
  enforce: 'post'
41
43
  },
42
- replaceSrcPaths(config)
44
+ {
45
+ name: 'replace-src-paths',
46
+ writeBundle: async () => {
47
+ const files = glob.sync(defaultSettings.distFolder + '/**/index.html');
48
+ for (const file of files) {
49
+ let html = await fs.promises.readFile(file, 'utf-8');
50
+ let updatedHtml = '';
51
+
52
+ if (config.pathSubdirectory && config.pathSubdirectory.length > 0) {
53
+ updatedHtml = html
54
+ .replace(/(src|data-load)="\/?src\//g, `$1="${config.pathSubdirectory}`)
55
+ .replace(/(src|srcset|data-load|href)="\/?assets\//g, `$1="${config.pathSubdirectory}assets/`)
56
+ .replace(/(src|data-load|href)="\/?resources\//g, `$1="${config.pathSubdirectory}resources/`)
57
+ } else {
58
+ updatedHtml = html.replace(/(src|data-load)="\/?src\//g, '$1="/');
59
+ }
60
+
61
+ await fs.promises.writeFile(file, updatedHtml);
62
+ }
63
+ },
64
+ apply: 'build',
65
+ }
43
66
  ],
44
67
  define: {
45
68
  'process.env': process.env