fix: use posix.resolve

This commit is contained in:
chenos 2025-01-10 10:42:35 +08:00
parent 5ecd48ad15
commit 80bd0e9870

View File

@ -7,7 +7,7 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
const { resolve } = require('path');
const { resolve, posix } = require('path');
const { Command } = require('commander');
const { readFileSync, writeFileSync } = require('fs');
@ -22,12 +22,12 @@ module.exports = (cli) => {
let otherLocation = '';
if (process.env.APP_PUBLIC_PATH !== '/') {
otherLocation = `location / {
alias {{cwd}}/node_modules/@nocobase/app/dist/client/;
alias ${posix.resolve(process.cwd())}/node_modules/@nocobase/app/dist/client/;
try_files $uri $uri/ /index.html;
}`;
}
const replaced = data
.replace(/\{\{cwd\}\}/g, '/app/nocobase')
.replace(/\{\{cwd\}\}/g, posix.resolve(process.cwd()))
.replace(/\{\{publicPath\}\}/g, process.env.APP_PUBLIC_PATH)
.replace(/\{\{apiPort\}\}/g, process.env.APP_PORT)
.replace(/\{\{otherLocation\}\}/g, otherLocation);