@_tc/template-core 0.0.1-bate.18 → 0.0.1-bate.19
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.
|
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const paths_1 = require("../../packages/core/paths");
|
|
6
7
|
const nunjucks_1 = __importDefault(require("nunjucks"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
7
9
|
exports.default = (app) => {
|
|
8
|
-
const viewsPath =
|
|
10
|
+
const viewsPath = path_1.default.join((0, paths_1.getAppPath)(app, 'frame'), "./app/public");
|
|
9
11
|
const env = nunjucks_1.default.configure(viewsPath, {
|
|
10
12
|
autoescape: true,
|
|
11
13
|
throwOnUndefined: false,
|
package/cjs/bundler/utils.js
CHANGED
|
@@ -108,8 +108,9 @@ function entries() {
|
|
|
108
108
|
return input;
|
|
109
109
|
}
|
|
110
110
|
function outDir() {
|
|
111
|
-
// 为了保持代码 能见性 输出地址应该为 runPath/app/public/dist
|
|
112
|
-
|
|
111
|
+
// // 为了保持代码 能见性 输出地址应该为 runPath/app/public/dist
|
|
112
|
+
// 放在框架路径比较保险
|
|
113
|
+
return path_1.default.join(frameNodePath, "./app/public/dist");
|
|
113
114
|
}
|
|
114
115
|
const watchFiles = async (callback) => {
|
|
115
116
|
const chokidar = await Promise.resolve().then(() => __importStar(require("chokidar")));
|
|
@@ -150,7 +151,13 @@ function flattenHtmlPlugin(suffix = ".html") {
|
|
|
150
151
|
const htmlFiles = glob.sync("**/*.html", { cwd: feDir });
|
|
151
152
|
for (const file of htmlFiles) {
|
|
152
153
|
const src = path_1.default.join(feDir, file);
|
|
153
|
-
|
|
154
|
+
let fileOName = path_1.default.basename(file, ".html");
|
|
155
|
+
// 如果文件名没有 entry 补上后缀
|
|
156
|
+
const entrySuffix = ".entry";
|
|
157
|
+
if (fileOName.indexOf(entrySuffix) === -1) {
|
|
158
|
+
fileOName = fileOName + entrySuffix;
|
|
159
|
+
}
|
|
160
|
+
const fileName = fileOName + suffix;
|
|
154
161
|
const dest = path_1.default.join(feDir, fileName);
|
|
155
162
|
if (src !== dest) {
|
|
156
163
|
(0, fs_1.copyFileSync)(src, dest);
|
|
@@ -187,7 +194,7 @@ const VBuildFE = async (input) => {
|
|
|
187
194
|
configFile: false,
|
|
188
195
|
plugins: [
|
|
189
196
|
(await Promise.resolve().then(() => __importStar(require("@vitejs/plugin-react")))).default(),
|
|
190
|
-
flattenHtmlPlugin(
|
|
197
|
+
flattenHtmlPlugin(".tpl"),
|
|
191
198
|
],
|
|
192
199
|
build: {
|
|
193
200
|
outDir: outDir(),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { getAppPath } from "../../packages/core/paths";
|
|
1
2
|
import nunjucks from "nunjucks";
|
|
3
|
+
import path from "path";
|
|
2
4
|
export default (app) => {
|
|
3
|
-
const viewsPath = app
|
|
5
|
+
const viewsPath = path.join(getAppPath(app, 'frame'), "./app/public");
|
|
4
6
|
const env = nunjucks.configure(viewsPath, {
|
|
5
7
|
autoescape: true,
|
|
6
8
|
throwOnUndefined: false,
|
package/esm/bundler/utils.js
CHANGED
|
@@ -67,8 +67,9 @@ export function entries() {
|
|
|
67
67
|
return input;
|
|
68
68
|
}
|
|
69
69
|
export function outDir() {
|
|
70
|
-
// 为了保持代码 能见性 输出地址应该为 runPath/app/public/dist
|
|
71
|
-
|
|
70
|
+
// // 为了保持代码 能见性 输出地址应该为 runPath/app/public/dist
|
|
71
|
+
// 放在框架路径比较保险
|
|
72
|
+
return path.join(frameNodePath, "./app/public/dist");
|
|
72
73
|
}
|
|
73
74
|
export const watchFiles = async (callback) => {
|
|
74
75
|
const chokidar = await import("chokidar");
|
|
@@ -108,7 +109,13 @@ function flattenHtmlPlugin(suffix = ".html") {
|
|
|
108
109
|
const htmlFiles = glob.sync("**/*.html", { cwd: feDir });
|
|
109
110
|
for (const file of htmlFiles) {
|
|
110
111
|
const src = path.join(feDir, file);
|
|
111
|
-
|
|
112
|
+
let fileOName = path.basename(file, ".html");
|
|
113
|
+
// 如果文件名没有 entry 补上后缀
|
|
114
|
+
const entrySuffix = ".entry";
|
|
115
|
+
if (fileOName.indexOf(entrySuffix) === -1) {
|
|
116
|
+
fileOName = fileOName + entrySuffix;
|
|
117
|
+
}
|
|
118
|
+
const fileName = fileOName + suffix;
|
|
112
119
|
const dest = path.join(feDir, fileName);
|
|
113
120
|
if (src !== dest) {
|
|
114
121
|
copyFileSync(src, dest);
|
|
@@ -145,7 +152,7 @@ export const VBuildFE = async (input) => {
|
|
|
145
152
|
configFile: false,
|
|
146
153
|
plugins: [
|
|
147
154
|
(await import("@vitejs/plugin-react")).default(),
|
|
148
|
-
flattenHtmlPlugin(
|
|
155
|
+
flattenHtmlPlugin(".tpl"),
|
|
149
156
|
],
|
|
150
157
|
build: {
|
|
151
158
|
outDir: outDir(),
|