@_tc/template-core 0.0.1-bate.41 → 0.0.1-bate.42
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/cjs/bundler/utils.js +15 -8
- package/esm/bundler/utils.js +15 -8
- package/package.json +1 -1
package/cjs/bundler/utils.js
CHANGED
|
@@ -97,24 +97,28 @@ var watchFiles = async (callback) => {
|
|
|
97
97
|
* 3. 移动内部的html 至 输出目录的根节点
|
|
98
98
|
*/
|
|
99
99
|
function flattenHtmlPlugin(suffix = ".html") {
|
|
100
|
+
const suffixes = [...new Set(Array.isArray(suffix) ? suffix : [suffix])];
|
|
100
101
|
return {
|
|
101
102
|
name: "flatten-html",
|
|
102
103
|
apply: "build",
|
|
103
104
|
closeBundle() {
|
|
104
105
|
const feDir = outDir();
|
|
105
106
|
if (!(0, fs.existsSync)(feDir)) return;
|
|
106
|
-
const htmlFiles = glob.sync("**/*.html", {
|
|
107
|
+
const htmlFiles = glob.sync("**/*.html", {
|
|
108
|
+
cwd: feDir,
|
|
109
|
+
dot: true
|
|
110
|
+
});
|
|
107
111
|
for (const file of htmlFiles) {
|
|
108
112
|
const src = path.default.join(feDir, file);
|
|
109
113
|
let fileOName = path.default.basename(file, ".html");
|
|
110
114
|
const entrySuffix = ".entry";
|
|
111
115
|
if (fileOName.indexOf(entrySuffix) === -1) fileOName = fileOName + entrySuffix;
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
(0, fs.copyFileSync)(src, dest);
|
|
116
|
-
(0, fs.unlinkSync)(src);
|
|
116
|
+
for (const currentSuffix of suffixes) {
|
|
117
|
+
const fileName = fileOName + currentSuffix;
|
|
118
|
+
const dest = path.default.join(feDir, fileName);
|
|
119
|
+
if (src !== dest) (0, fs.copyFileSync)(src, dest);
|
|
117
120
|
}
|
|
121
|
+
if (!suffixes.some((currentSuffix) => src === path.default.join(feDir, fileOName + currentSuffix))) (0, fs.unlinkSync)(src);
|
|
118
122
|
}
|
|
119
123
|
const parents = [...new Set(htmlFiles.map((f) => path.default.dirname(f)))].sort().reverse();
|
|
120
124
|
/**
|
|
@@ -132,7 +136,10 @@ function flattenHtmlPlugin(suffix = ".html") {
|
|
|
132
136
|
/**
|
|
133
137
|
* ------------------
|
|
134
138
|
*/
|
|
135
|
-
const endFiles = glob.sync("**/*" +
|
|
139
|
+
const endFiles = suffixes.flatMap((currentSuffix) => glob.sync("**/*" + currentSuffix, {
|
|
140
|
+
cwd: feDir,
|
|
141
|
+
dot: true
|
|
142
|
+
}));
|
|
136
143
|
for (const f of endFiles) require_packages_common_log_index.logYellow("final file path -----> " + f);
|
|
137
144
|
}
|
|
138
145
|
};
|
|
@@ -164,7 +171,7 @@ var VBuildFE = async (input, OperatingEnv) => {
|
|
|
164
171
|
base: "/dist",
|
|
165
172
|
plugins: [
|
|
166
173
|
(await import("@vitejs/plugin-react")).default(),
|
|
167
|
-
flattenHtmlPlugin(".tpl"),
|
|
174
|
+
flattenHtmlPlugin([".tpl", ".html"]),
|
|
168
175
|
(0, _tailwindcss_vite.default)()
|
|
169
176
|
],
|
|
170
177
|
build: {
|
package/esm/bundler/utils.js
CHANGED
|
@@ -92,24 +92,28 @@ var watchFiles = async (callback) => {
|
|
|
92
92
|
* 3. 移动内部的html 至 输出目录的根节点
|
|
93
93
|
*/
|
|
94
94
|
function flattenHtmlPlugin(suffix = ".html") {
|
|
95
|
+
const suffixes = [...new Set(Array.isArray(suffix) ? suffix : [suffix])];
|
|
95
96
|
return {
|
|
96
97
|
name: "flatten-html",
|
|
97
98
|
apply: "build",
|
|
98
99
|
closeBundle() {
|
|
99
100
|
const feDir = outDir();
|
|
100
101
|
if (!existsSync(feDir)) return;
|
|
101
|
-
const htmlFiles = glob.sync("**/*.html", {
|
|
102
|
+
const htmlFiles = glob.sync("**/*.html", {
|
|
103
|
+
cwd: feDir,
|
|
104
|
+
dot: true
|
|
105
|
+
});
|
|
102
106
|
for (const file of htmlFiles) {
|
|
103
107
|
const src = path.join(feDir, file);
|
|
104
108
|
let fileOName = path.basename(file, ".html");
|
|
105
109
|
const entrySuffix = ".entry";
|
|
106
110
|
if (fileOName.indexOf(entrySuffix) === -1) fileOName = fileOName + entrySuffix;
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
copyFileSync(src, dest);
|
|
111
|
-
unlinkSync(src);
|
|
111
|
+
for (const currentSuffix of suffixes) {
|
|
112
|
+
const fileName = fileOName + currentSuffix;
|
|
113
|
+
const dest = path.join(feDir, fileName);
|
|
114
|
+
if (src !== dest) copyFileSync(src, dest);
|
|
112
115
|
}
|
|
116
|
+
if (!suffixes.some((currentSuffix) => src === path.join(feDir, fileOName + currentSuffix))) unlinkSync(src);
|
|
113
117
|
}
|
|
114
118
|
const parents = [...new Set(htmlFiles.map((f) => path.dirname(f)))].sort().reverse();
|
|
115
119
|
/**
|
|
@@ -127,7 +131,10 @@ function flattenHtmlPlugin(suffix = ".html") {
|
|
|
127
131
|
/**
|
|
128
132
|
* ------------------
|
|
129
133
|
*/
|
|
130
|
-
const endFiles = glob.sync("**/*" +
|
|
134
|
+
const endFiles = suffixes.flatMap((currentSuffix) => glob.sync("**/*" + currentSuffix, {
|
|
135
|
+
cwd: feDir,
|
|
136
|
+
dot: true
|
|
137
|
+
}));
|
|
131
138
|
for (const f of endFiles) logYellow("final file path -----> " + f);
|
|
132
139
|
}
|
|
133
140
|
};
|
|
@@ -159,7 +166,7 @@ var VBuildFE = async (input, OperatingEnv) => {
|
|
|
159
166
|
base: "/dist",
|
|
160
167
|
plugins: [
|
|
161
168
|
(await import("@vitejs/plugin-react")).default(),
|
|
162
|
-
flattenHtmlPlugin(".tpl"),
|
|
169
|
+
flattenHtmlPlugin([".tpl", ".html"]),
|
|
163
170
|
tailwindcss()
|
|
164
171
|
],
|
|
165
172
|
build: {
|